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

chore(server): refactoring id project and workspace [VIZ-BE-574] #1426

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

Conversation

hexaforce
Copy link
Contributor

@hexaforce hexaforce commented Feb 17, 2025

Overview

Refactoring ids

What I've done

This pull request unifies the project and workspace IDs to the ones in ./server/pkg/id/id.go.

I removed the parts that were redefining the ID from id.go.

  • type ProjectID
  • type WorkspaceID

What I haven't done

How I tested

Which point I want you to review particularly

Memo

Each package has its own id.go.

$ find . -name id.go
./server/pkg/id/id.go
./server/pkg/asset/id.go
./server/pkg/property/id.go
./server/pkg/dataset/id.go
./server/pkg/plugin/id.go
./server/pkg/nlslayer/id.go
./server/pkg/project/id.go
./server/pkg/layer/id.go
./server/pkg/storytelling/id.go
./server/pkg/scene/id.go
./server/pkg/tag/id.go

Ideal Refactoring

Ideally, we should keep only ./server/pkg/id/id.go and remove the id.go files in each package.

Summary by CodeRabbit

Summary by CodeRabbit

  • Refactor
    • Enhanced identifier types across core modules for improved clarity and consistency.
  • Tests
    • Updated test cases to align with the refined identifier types, ensuring continued accuracy and reliability.

These internal improvements streamline the system’s foundations without affecting end-user functionality.


This change is Reviewable

@hexaforce hexaforce requested a review from pyshx as a code owner February 17, 2025 03:43
Copy link

coderabbitai bot commented Feb 17, 2025

Warning

Rate limit exceeded

@hexaforce has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 36 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 3657355 and d8c9407.

⛔ Files ignored due to path filters (6)
  • server/e2e/test.zip is excluded by !**/*.zip
  • server/go.sum is excluded by !**/*.sum
  • server/pkg/layer/decoding/shapetest/shapes.zip is excluded by !**/*.zip
  • web/src/services/gql/__gen__/fragmentMatcher.json is excluded by !**/__gen__/**
  • web/src/services/gql/__gen__/gql.ts is excluded by !**/__gen__/**
  • web/src/services/gql/__gen__/graphql.ts is excluded by !**/__gen__/**
📒 Files selected for processing (107)
  • server/Makefile (3 hunks)
  • server/e2e/common.go (7 hunks)
  • server/e2e/gql_asset_test.go (6 hunks)
  • server/e2e/gql_me_test.go (1 hunks)
  • server/e2e/gql_project_export_import_test.go (3 hunks)
  • server/e2e/gql_project_export_test.go (0 hunks)
  • server/e2e/gql_project_test.go (6 hunks)
  • server/e2e/gql_scene_test.go (4 hunks)
  • server/e2e/gql_storytelling_test.go (6 hunks)
  • server/e2e/gql_user_test.go (2 hunks)
  • server/e2e/gql_validate_geojson_test.go (1 hunks)
  • server/e2e/mock_test.go (1 hunks)
  • server/e2e/ping_test.go (1 hunks)
  • server/e2e/seeder.go (5 hunks)
  • server/go.mod (1 hunks)
  • server/gql/asset.graphql (5 hunks)
  • server/gql/layer.graphql (0 hunks)
  • server/gql/property.graphql (0 hunks)
  • server/gql/storytelling.graphql (3 hunks)
  • server/gql/workspace.graphql (2 hunks)
  • server/gqlgen.yml (0 hunks)
  • server/internal/adapter/gql/gqldataloader/dataloader.go (0 hunks)
  • server/internal/adapter/gql/gqldataloader/layergrouploader_gen.go (0 hunks)
  • server/internal/adapter/gql/gqldataloader/layeritemloader_gen.go (0 hunks)
  • server/internal/adapter/gql/gqldataloader/layerloader_gen.go (0 hunks)
  • server/internal/adapter/gql/gqlmodel/convert_asset.go (1 hunks)
  • server/internal/adapter/gql/gqlmodel/convert_layer.go (0 hunks)
  • server/internal/adapter/gql/gqlmodel/convert_nlslayer_test.go (5 hunks)
  • server/internal/adapter/gql/gqlmodel/convert_project.go (2 hunks)
  • server/internal/adapter/gql/gqlmodel/convert_property.go (2 hunks)
  • server/internal/adapter/gql/gqlmodel/convert_storytelling.go (1 hunks)
  • server/internal/adapter/gql/gqlmodel/models.go (0 hunks)
  • server/internal/adapter/gql/gqlmodel/models_gen.go (5 hunks)
  • server/internal/adapter/gql/gqlmodel/scalar_id.go (0 hunks)
  • server/internal/adapter/gql/loader.go (0 hunks)
  • server/internal/adapter/gql/loader_asset.go (2 hunks)
  • server/internal/adapter/gql/loader_layer.go (0 hunks)
  • server/internal/adapter/gql/loader_property.go (1 hunks)
  • server/internal/adapter/gql/resolver_Storytelling.go (0 hunks)
  • server/internal/adapter/gql/resolver_layer.go (0 hunks)
  • server/internal/adapter/gql/resolver_mutation_asset.go (3 hunks)
  • server/internal/adapter/gql/resolver_mutation_project.go (6 hunks)
  • server/internal/adapter/gql/resolver_mutation_property.go (0 hunks)
  • server/internal/adapter/gql/resolver_mutation_storytelling.go (1 hunks)
  • server/internal/adapter/gql/resolver_property.go (0 hunks)
  • server/internal/adapter/gql/resolver_query.go (1 hunks)
  • server/internal/adapter/gql/resolver_team.go (1 hunks)
  • server/internal/adapter/http/dataset.go (0 hunks)
  • server/internal/app/app.go (2 hunks)
  • server/internal/app/auth_client.go (1 hunks)
  • server/internal/app/private.go (0 hunks)
  • server/internal/infrastructure/fs/file.go (2 hunks)
  • server/internal/infrastructure/fs/file_test.go (3 hunks)
  • server/internal/infrastructure/memory/asset.go (1 hunks)
  • server/internal/infrastructure/memory/container.go (0 hunks)
  • server/internal/infrastructure/memory/dataset.go (0 hunks)
  • server/internal/infrastructure/memory/dataset_schema.go (0 hunks)
  • server/internal/infrastructure/memory/layer.go (0 hunks)
  • server/internal/infrastructure/memory/layer_test.go (0 hunks)
  • server/internal/infrastructure/memory/project.go (1 hunks)
  • server/internal/infrastructure/memory/property.go (1 hunks)
  • server/internal/infrastructure/memory/scene.go (1 hunks)
  • server/internal/infrastructure/memory/tag.go (0 hunks)
  • server/internal/infrastructure/memory/tag_test.go (0 hunks)
  • server/internal/infrastructure/mongo/asset.go (2 hunks)
  • server/internal/infrastructure/mongo/container.go (2 hunks)
  • server/internal/infrastructure/mongo/dataset.go (0 hunks)
  • server/internal/infrastructure/mongo/dataset_schema.go (0 hunks)
  • server/internal/infrastructure/mongo/layer.go (0 hunks)
  • server/internal/infrastructure/mongo/layer_test.go (0 hunks)
  • server/internal/infrastructure/mongo/mongodoc/asset.go (3 hunks)
  • server/internal/infrastructure/mongo/mongodoc/dataset.go (0 hunks)
  • server/internal/infrastructure/mongo/mongodoc/dataset_schema.go (0 hunks)
  • server/internal/infrastructure/mongo/mongodoc/layer.go (0 hunks)
  • server/internal/infrastructure/mongo/mongodoc/property.go (0 hunks)
  • server/internal/infrastructure/mongo/mongodoc/scene.go (0 hunks)
  • server/internal/infrastructure/mongo/mongodoc/storytelling.go (4 hunks)
  • server/internal/infrastructure/mongo/mongodoc/tag.go (0 hunks)
  • server/internal/infrastructure/mongo/mongodoc/tag_test.go (0 hunks)
  • server/internal/infrastructure/mongo/property.go (0 hunks)
  • server/internal/infrastructure/mongo/scene.go (1 hunks)
  • server/internal/infrastructure/mongo/tag.go (0 hunks)
  • server/internal/usecase/gateway/container.go (0 hunks)
  • server/internal/usecase/gateway/datasouce.go (0 hunks)
  • server/internal/usecase/interactor/asset.go (6 hunks)
  • server/internal/usecase/interactor/common.go (1 hunks)
  • server/internal/usecase/interactor/dataset.go (0 hunks)
  • server/internal/usecase/interactor/layer.go (0 hunks)
  • server/internal/usecase/interactor/layer_test.go (0 hunks)
  • server/internal/usecase/interactor/nlslayer.go (13 hunks)
  • server/internal/usecase/interactor/plugin.go (0 hunks)
  • server/internal/usecase/interactor/plugin_upload.go (1 hunks)
  • server/internal/usecase/interactor/plugin_upload_test.go (1 hunks)
  • server/internal/usecase/interactor/project.go (7 hunks)
  • server/internal/usecase/interactor/project_test.go (0 hunks)
  • server/internal/usecase/interactor/property.go (0 hunks)
  • server/internal/usecase/interactor/scene.go (6 hunks)
  • server/internal/usecase/interactor/scene_plugin.go (3 hunks)
  • server/internal/usecase/interactor/scene_plugin_test.go (2 hunks)
  • server/internal/usecase/interactor/storytelling.go (5 hunks)
  • server/internal/usecase/interactor/storytelling_test.go (1 hunks)
  • server/internal/usecase/interactor/tag.go (0 hunks)
  • server/internal/usecase/interfaces/asset.go (2 hunks)
  • server/internal/usecase/interfaces/common.go (0 hunks)
  • server/internal/usecase/interfaces/dataset.go (0 hunks)
  • server/internal/usecase/interfaces/layer.go (0 hunks)
  • server/internal/usecase/interfaces/project.go (2 hunks)

Walkthrough

This pull request refactors multiple type declarations and method signatures across various packages. The changes update identifiers for projects and workspaces to use more explicit types from the id and accountdomain packages instead of local aliases. Several type aliases have been removed or commented out, and corresponding import statements have been added where necessary. No changes to the underlying logic, control flow, or error handling are introduced.

Changes

File(s) Change Summary
server/internal/infrastructure/memory/project.go Updated FindIDsByWorkspace return type from project.ID to id.ProjectID.
server/pkg/asset/asset.go, server/pkg/asset/asset_test.go, server/pkg/asset/builder.go, server/pkg/asset/builder_test.go, server/pkg/asset/id.go Changed Asset struct fields and methods from WorkspaceID to accountdomain.WorkspaceID; removed the WorkspaceID type alias in id.go.
server/pkg/project/builder.go, server/pkg/project/builder_test.go, server/pkg/project/id.go, server/pkg/project/project.go Updated project-related identifiers: changed from generic ID/WorkspaceID to id.ProjectID/accountdomain.WorkspaceID; removed type aliases in id.go and updated method signatures.
server/pkg/scene/builder.go, server/pkg/scene/builder_test.go, server/pkg/scene/id.go, server/pkg/scene/list.go, server/pkg/scene/scene.go Modified scene-related identifiers: updated parameters and struct fields from ProjectID/WorkspaceID to id.ProjectID/accountdomain.WorkspaceID; removed type aliases in id.go and adjusted method signatures accordingly.
server/internal/infrastructure/memory/scene.go, server/internal/infrastructure/mongo/container.go, server/internal/infrastructure/mongo/scene.go, server/internal/usecase/operator.go, server/internal/usecase/repo/container_test.go Removed references to the user package and updated method signatures to use accountdomain.WorkspaceIDList instead of user.WorkspaceIDList.

Sequence Diagram(s)

(No sequence diagrams applicable for these type and signature refinements.)

Possibly related PRs

  • chore(server): refactoring id Layer and NLSLayer #1430: The changes in the main PR, which involve updating the return type of the FindIDsByWorkspace method in the Project struct, are related to the changes in the retrieved PR that also focus on modifying identifier types, specifically transitioning to more specific types like id.ProjectID, indicating a consistent approach to type management across the codebase.
  • feat(server): associate project asset #1410: The changes in the main PR, which involve updating the method signature of FindIDsByWorkspace in the Project struct to return a different type of project identifier, are related to the modifications in the retrieved PR that enhance asset management by associating assets with projects, specifically through the introduction of a projectId parameter in various asset-related structures and methods. Both PRs focus on improving the handling of project identifiers within their respective contexts.

Suggested reviewers

  • pyshx
  • soneda-yuya
  • mkumbobeaty

Poem

I'm a bunny with a hop so light,
Refactoring types throughout the night.
Workspace and project IDs now align,
Code carrots crisp, fresh, and fine!
My whiskers twitch with delight 🥕,
Celebrating changes, oh so bright!
Hop on over to give it a sight!


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.
  • @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 17, 2025

Deploy Preview for reearth-web canceled.

Name Link
🔨 Latest commit d8c9407
🔍 Latest deploy log https://app.netlify.com/sites/reearth-web/deploys/67bff130c7e5100008d547f3

@hexaforce hexaforce force-pushed the chore/refactoring-id-project-workspace branch from 3b20fa5 to d736d7f Compare February 17, 2025 08:31
@@ -6,7 +6,8 @@ import (
)

type ID = id.AssetID
type WorkspaceID = accountdomain.WorkspaceID

// type WorkspaceID = accountdomain.WorkspaceID
Copy link
Contributor

Choose a reason for hiding this comment

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

@hexaforce
if this line isn't needed, could you delete this comment?

Copy link
Contributor Author

@hexaforce hexaforce Feb 17, 2025

Choose a reason for hiding this comment

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

ok. fixed

Copy link
Contributor

@soneda-yuya soneda-yuya left a comment

Choose a reason for hiding this comment

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

@hexaforce
I have a comment!
Could you confirm it?
But LGTM!

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: 0

🧹 Nitpick comments (1)
server/internal/usecase/operator.go (1)

49-49: Fix typo in method name.

The method name should be pluralized for consistency with other methods.

-func (o *Operator) AllMaintainingWorkspace() accountdomain.WorkspaceIDList {
+func (o *Operator) AllMaintainingWorkspaces() accountdomain.WorkspaceIDList {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d736d7f and e429003.

📒 Files selected for processing (5)
  • server/internal/infrastructure/memory/scene.go (1 hunks)
  • server/internal/infrastructure/mongo/container.go (2 hunks)
  • server/internal/infrastructure/mongo/scene.go (1 hunks)
  • server/internal/usecase/operator.go (1 hunks)
  • server/internal/usecase/repo/container_test.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Redirect rules - reearth-web
  • GitHub Check: Header rules - reearth-web
  • GitHub Check: Pages changed - reearth-web
  • GitHub Check: ci-server / ci-server-lint
  • GitHub Check: ci-server / ci-server-test
🔇 Additional comments (6)
server/internal/usecase/repo/container_test.go (1)

25-28: LGTM! Test coverage looks comprehensive.

The changes correctly standardize on accountdomain.WorkspaceIDList while maintaining thorough test coverage for workspace filter merging, including edge cases with empty lists.

server/internal/infrastructure/memory/scene.go (1)

88-88: LGTM! Clean transition to accountdomain package.

The change correctly uses accountdomain.WorkspaceIDList while maintaining the existing thread-safe implementation and error handling.

server/internal/infrastructure/mongo/scene.go (1)

77-77: LGTM! MongoDB query updated correctly.

The change appropriately uses accountdomain.WorkspaceIDList while maintaining the correct MongoDB query structure and error handling.

server/internal/usecase/operator.go (1)

41-54: LGTM! Return types updated consistently.

The changes correctly standardize on accountdomain.WorkspaceIDList across all workspace-related methods.

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

15-15: LGTM! Import statement updated to use consolidated package.

The change aligns with the PR objective of unifying ID definitions by using the consolidated accountdomain package instead of the specific user subpackage.


137-137: LGTM! Function signature updated to use consolidated type.

The parameter type change from user.WorkspaceIDList to accountdomain.WorkspaceIDList aligns with the PR objective of unifying workspace ID definitions. The function logic remains unchanged, ensuring backward compatibility.

@hexaforce hexaforce enabled auto-merge (squash) February 18, 2025 03:04
Copy link
Contributor

@pyshx pyshx left a comment

Choose a reason for hiding this comment

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

Reviewed 14 of 15 files at r1, 5 of 5 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @soneda-yuya)

@hexaforce hexaforce force-pushed the chore/refactoring-id-project-workspace branch from 08a69aa to 3657355 Compare February 26, 2025 09:52
@github-actions github-actions bot added the web label Feb 27, 2025
@hexaforce hexaforce force-pushed the chore/refactoring-id-project-workspace branch 4 times, most recently from 8d1ed59 to 90d517d Compare February 27, 2025 03:34
@hexaforce hexaforce force-pushed the chore/refactoring-id-project-workspace branch from 90d517d to 981ce22 Compare February 27, 2025 03:35
@hexaforce hexaforce changed the title chore(server): refactoring id project and workspace chore(server): refactoring id project and workspace [VIZ-BE-574] Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants