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

feat(server): get only what hasn't been deleted #1179

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

hexaforce
Copy link
Contributor

@hexaforce hexaforce commented Oct 16, 2024

Overview

Get only what hasn't been deleted

What I've done

Query projects only for non-deleted items

What I haven't done

How I tested

Which point I want you to review particularly

Memo

Summary by CodeRabbit

  • New Features
    • Enhanced project retrieval by filtering out deleted projects, ensuring users only see active projects in their workspace.
  • Bug Fixes
    • Corrected project querying to exclude deleted entries, improving the accuracy of project listings.

@hexaforce hexaforce requested a review from pyshx as a code owner October 16, 2024 07:14
Copy link

coderabbitai bot commented Oct 16, 2024

Walkthrough

The pull request modifies the FindByWorkspace method in the Project struct within two files: project.go in the memory and mongo directories. The method now includes a condition to filter out deleted projects, ensuring that only non-deleted projects are returned when querying by workspace. Minor formatting adjustments were made in the mongo file, but the overall structure and other methods remain unchanged.

Changes

File Path Change Summary
server/internal/infrastructure/memory/project.go, server/internal/infrastructure/mongo/project.go Updated the FindByWorkspace method to filter out deleted projects by adding conditions to the query. Minor formatting adjustments in the mongo file.

Possibly related PRs

  • fix(web): update projects cache after delete #1167: This PR updates the cache after a project is deleted, which relates to the main PR's focus on filtering out deleted projects in the FindByWorkspace method, ensuring that both PRs address the handling of project deletion.

Suggested labels

server

Suggested reviewers

  • pyshx

🐰 In the garden where projects grow,
We filter out the ones below.
No deleted dreams shall take their place,
Only the bright ones in this space!
With every query, clear and bright,
Our workspace shines with pure delight! 🌼


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 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 Oct 16, 2024

Deploy Preview for reearth-web canceled.

Name Link
🔨 Latest commit bcffbf5
🔍 Latest deploy log https://app.netlify.com/sites/reearth-web/deploys/670f67e9d54a540008c12e27

Copy link

@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

📥 Commits

Files that changed from the base of the PR and between b1c2db4 and bcffbf5.

📒 Files selected for processing (2)
  • server/internal/infrastructure/memory/project.go (1 hunks)
  • server/internal/infrastructure/mongo/project.go (1 hunks)
🧰 Additional context used
🔇 Additional comments (3)
server/internal/infrastructure/memory/project.go (1)

48-48: LGTM! Verify consistency across implementations.

The addition of !d.IsDeleted() to the condition effectively filters out deleted projects, aligning with the PR objective. This change improves the query's accuracy by returning only active projects.

To ensure consistency, please verify that similar changes have been made in other storage implementations (e.g., MongoDB). Run the following script to check for consistency:

This script will help identify if the IsDeleted() check has been consistently implemented across different storage backends.

server/internal/infrastructure/mongo/project.go (2)

87-88: LGTM: Filter non-deleted projects as intended.

The addition of "deleted": false to the filter aligns with the PR objective to query only non-deleted projects. This change improves the method's functionality and potentially its performance.


87-88: Verify impact on other parts of the codebase.

The change to filter out deleted projects by default might affect other parts of the codebase that expect all projects to be returned. It's important to verify that this change doesn't introduce unexpected behavior elsewhere.

To help identify potential issues, you can run the following script:

Please review the results to ensure that all usages of FindByWorkspace and handling of deleted projects are consistent with this change.

✅ Verification successful

Verification Successful: No Impact Detected

The change to filter out deleted projects by default has been reviewed across the codebase. Existing methods like FindDeletedByWorkspace and corresponding tests ensure that handling of deleted projects remains consistent and unaffected by this default filter.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for usages of FindByWorkspace to identify potential impacts

# Test: Search for FindByWorkspace method calls
echo "Searching for FindByWorkspace method calls:"
rg --type go "FindByWorkspace\(" -A 3

# Test: Search for any references to deleted projects
echo "\nSearching for references to deleted projects:"
rg --type go "deleted.*project" -i

Length of output: 14394

@pyshx pyshx changed the title feat(server): Get only what hasn't been deleted feat(server): get only what hasn't been deleted Oct 16, 2024
@hexaforce hexaforce merged commit fc1a295 into main Oct 16, 2024
18 checks passed
@hexaforce hexaforce deleted the feat/project-query-notdeleted-filter branch October 16, 2024 08:05
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.

2 participants