Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): ensure head deployment retrieval for projects and workspaces #839

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kasugamirai
Copy link
Member

@kasugamirai kasugamirai commented Feb 6, 2025

Overview

What I've done

What I haven't done

How I tested

Screenshot

Which point I want you to review particularly

Memo

Summary by CodeRabbit

  • New Features

    • Deployment listings now display only the primary version, ensuring consistency in what’s shown.
    • New deployments start with version "v1" for improved versioning consistency.
  • Tests

    • Updated testing routines to validate the updated deployment behavior.

@kasugamirai kasugamirai requested a review from pyshx as a code owner February 6, 2025 05:57
Copy link
Contributor

coderabbitai bot commented Feb 6, 2025

Warning

Rate limit exceeded

@kasugamirai has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 50 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 0eeeb59 and 2e29169.

📒 Files selected for processing (1)
  • api/internal/usecase/interactor/deployment.go (1 hunks)

Walkthrough

The pull request modifies how deployments are filtered and versioned. Both in-memory and Mongo implementations of the FindByProject method now ensure that only head deployments are retrieved. Corresponding tests have been updated to mark deployments as head. Additionally, the deployment creation logic has been revised: deployments without an associated project now start with version "v1" instead of "v0", while the head designation and version increment rules remain intact.

Changes

Files Change Summary
api/.../infrastructure/memory/deployment.go
api/.../infrastructure/mongo/deployment.go
Updated the FindByProject methods to restrict retrieval to head deployments. The memory implementation now checks d.IsHead(), and the Mongo adapter adds an "ishead": true filter to the query.
api/.../infrastructure/memory/deployment_test.go Modified tests by adding .IsHead(true) during deployment creation to ensure the deployment object is marked as the head version.
api/.../usecase/interactor/deployment.go Changed the deployment creation logic so that deployments default to version "v1" when no project is set, replacing the earlier default of "v0". The handling of head deployments during version increments remains unchanged.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Repository
    participant DeploymentService

    Client->>DeploymentService: Request deployment by project ID
    DeploymentService->>Repository: Call FindByProject(projectID)
    Repository-->>DeploymentService: Check if (d.Project != nil) && (d.Project == id) && (d.IsHead())
    DeploymentService-->>Client: Return head deployment if exists
Loading
sequenceDiagram
    participant Caller
    participant Interactor
    participant Repository

    Caller->>Interactor: Create deployment (with or without project)
    Interactor->>Repository: Check for existing head deployment
    alt Head exists
        Interactor->>Repository: Mark existing deployment as non-head
        Interactor->>Interactor: Increment version
    else No head exists
        Interactor->>Interactor: Set version to "v1"
    end
    Interactor-->>Caller: Return new deployment as head
Loading

Possibly related PRs

Suggested reviewers

  • pyshx

Poem

In the meadow of code I hop and play,
Head deployments now guide the way.
A version "v1" sprouts in the light,
With tests ensuring the future is bright.
🐰 Code rabbits rejoice, with leaps so gay!
Happy coding from the burrow today!

(ASCII art bunny: (_/))
( •_•)
/ >🍃


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Feb 6, 2025

Deploy Preview for reearth-flow canceled.

Name Link
🔨 Latest commit 2df07a1
🔍 Latest deploy log https://app.netlify.com/sites/reearth-flow/deploys/67a4ba2a791cf000080a703f

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1621370 and 0eeeb59.

📒 Files selected for processing (4)
  • api/internal/infrastructure/memory/deployment.go (1 hunks)
  • api/internal/infrastructure/memory/deployment_test.go (1 hunks)
  • api/internal/infrastructure/mongo/deployment.go (1 hunks)
  • api/internal/usecase/interactor/deployment.go (1 hunks)
🔇 Additional comments (3)
api/internal/infrastructure/memory/deployment_test.go (1)

27-27: LGTM! Test updated to reflect head deployment changes.

The test has been correctly updated to mark the deployment as head, which aligns with the new implementation.

api/internal/infrastructure/memory/deployment.go (1)

123-123: LGTM! Head deployment filtering added.

The FindByProject method now correctly filters for head deployments, ensuring consistent behavior with the MongoDB implementation.

api/internal/infrastructure/mongo/deployment.go (1)

135-135: LGTM! MongoDB query updated for head deployments.

The MongoDB query now correctly filters for head deployments, ensuring consistent behavior with the memory implementation.

api/internal/usecase/interactor/deployment.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Feb 6, 2025

Codecov Report

Attention: Patch coverage is 6.66667% with 14 lines in your changes missing coverage. Please review.

Project coverage is 25.61%. Comparing base (de402d2) to head (2e29169).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
api/internal/usecase/interactor/deployment.go 0.00% 13 Missing ⚠️
api/internal/infrastructure/mongo/deployment.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #839      +/-   ##
==========================================
+ Coverage   25.56%   25.61%   +0.04%     
==========================================
  Files         138      138              
  Lines        8073     8180     +107     
==========================================
+ Hits         2064     2095      +31     
- Misses       5806     5877      +71     
- Partials      203      208       +5     
Flag Coverage Δ
api 25.61% <6.66%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
api/internal/infrastructure/memory/deployment.go 63.79% <100.00%> (-9.78%) ⬇️
api/internal/infrastructure/mongo/deployment.go 0.00% <0.00%> (ø)
api/internal/usecase/interactor/deployment.go 0.00% <0.00%> (ø)

... and 6 files with indirect coverage changes

@kasugamirai kasugamirai enabled auto-merge (squash) February 7, 2025 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant