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: ensure models generated Store trait exposes set/update/delete #2348

Merged
merged 4 commits into from
Aug 27, 2024

Conversation

glihm
Copy link
Collaborator

@glihm glihm commented Aug 27, 2024

Description

Due to low compiler inference capabilities, the Store traits generated for Model and ModelEntity were not including the set, delete or update function. Which, in some projects resulted in low devX to use the Store API for models.

Summary by CodeRabbit

  • New Features

    • Introduced new methods for updating and deleting entities in the application, enhancing functionality and clarity.
  • Improvements

    • Renamed existing methods to improve semantic clarity, ensuring that method names accurately reflect their operations (e.g., set to set_model, delete to delete_model).
  • Bug Fixes

    • Resolved ambiguities in method usage by renaming methods in various traits, which enhances maintainability and readability across the codebase.
  • Tests

    • Enhanced testing capabilities by adding CaseStore to the imports in the benchmark tests, allowing for more comprehensive testing scenarios.

Copy link

coderabbitai bot commented Aug 27, 2024

Walkthrough

Ohayo, sensei! The changes involve renaming multiple methods across various files to enhance clarity and reduce ambiguity. Key methods associated with models and entities have been updated to better reflect their purposes, such as changing set to set_model and delete to delete_model. Additionally, new methods for updating and deleting entities have been introduced in specific implementations to improve functionality.

Changes

Files Change Summary
crates/dojo-core/src/model/metadata.cairo, crates/dojo-core/src/model/model.cairo Renamed methods in ResourceMetadataModel, ModelEntity, and Model to clarify context: set to set_model, delete to delete_model, update to update_entity.
crates/dojo-lang/src/inline_macros/delete.rs, crates/dojo-lang/src/inline_macros/set.rs Updated method calls from delete to delete_model and set to set_model in DeleteMacro and SetMacro implementations, respectively.
crates/dojo-lang/src/model.rs Introduced new update and delete methods in EntityStoreImpl and StoreImpl, and renamed existing methods in ModelEntityImpl and ModelImpl for clarity.
crates/dojo-lang/src/semantics/test_data/set Changed function reference from set to set_model in StatementExpr, reflecting a more specific operation related to model setting.
crates/dojo-core/src/tests/benchmarks.cairo Added CaseStore to imports in benchmarks.cairo to enhance testing capabilities.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EntityStoreImpl
    participant ModelEntity
    participant ModelImpl
    
    User->>EntityStoreImpl: update(entity)
    EntityStoreImpl->>ModelEntity: update_entity(entity)
    ModelEntity-->>EntityStoreImpl: success

    User->>EntityStoreImpl: delete(entity)
    EntityStoreImpl->>ModelEntity: delete_entity(entity)
    ModelEntity-->>EntityStoreImpl: success

    User->>ModelImpl: set(model)
    ModelImpl->>Model: set_model(model)
    Model-->>ModelImpl: success

    User->>ModelImpl: delete(model)
    ModelImpl->>Model: delete_model(model)
    Model-->>ModelImpl: success
Loading

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6c5d50f and 7105b89.

Files selected for processing (1)
  • crates/dojo-core/src/tests/benchmarks.cairo (1 hunks)
Files skipped from review due to trivial changes (1)
  • crates/dojo-core/src/tests/benchmarks.cairo

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

codecov bot commented Aug 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.51%. Comparing base (f9606d8) to head (7105b89).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2348      +/-   ##
==========================================
+ Coverage   67.27%   67.51%   +0.24%     
==========================================
  Files         357      359       +2     
  Lines       46649    46853     +204     
==========================================
+ Hits        31383    31634     +251     
+ Misses      15266    15219      -47     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@glihm glihm merged commit e1a349b into dojoengine:main Aug 27, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant