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

opt-fix(torii-core): fix and optimize partial updates #2427

Merged
merged 8 commits into from
Sep 16, 2024

Conversation

Larkooo
Copy link
Collaborator

@Larkooo Larkooo commented Sep 14, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced data handling for member types, improving the organization of stored entities.
    • Introduced new processors for updating members and records, expanding event handling capabilities.
  • Bug Fixes

    • Resolved issues related to unnecessary key retrieval steps in the entity update process.
  • Refactor

    • Removed outdated methods for managing model members and entity keys, streamlining the codebase.
  • Documentation

    • Updated method signatures to reflect changes in handling entity keys and member types.

Copy link

coderabbitai bot commented Sep 14, 2024

Walkthrough

Ohayo, sensei! The changes in this pull request focus on modifying the handling of entity types and keys within the database operations in the torii crate. Key updates include the introduction of structured data representations, simplification of key management during entity updates, and significant alterations to the set_entity method in the SQL implementation. These modifications aim to enhance the organization and clarity of data processing in the system.

Changes

Files Change Summary
crates/torii/core/src/processors/store_update_member.rs Introduced Struct import; wrapped member in Ty::Struct for structured data representation.
crates/torii/core/src/processors/store_update_record.rs Simplified key handling by using existing schema; removed explicit key retrieval and concatenation.
crates/torii/core/src/processors/store_set_record.rs Modified set_entity to accept Option<&str> for keys, enhancing flexibility in handling input.
crates/torii/core/src/sql.rs Modified set_entity to accept Option<&str> for keys; removed set_model_member and related methods.
crates/torii/libp2p/src/server/mod.rs Changed set_entity to accept Option<&str> for keys, allowing for optional key handling.
crates/torii/core/src/sql_test.rs Added StoreUpdateMemberProcessor and StoreUpdateRecordProcessor; introduced new test for record updates.

Possibly related PRs

  • refactor(torii): update query logic for them to not block #2397: The changes in sql.rs related to the set_entity method are directly relevant, as they involve modifications to how entities are inserted and updated in the database, which aligns with the main PR's focus on altering the handling of entity types and the set_entity method.

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c210a64 and 6a3ed4a.

Files selected for processing (1)
  • crates/torii/graphql/src/tests/subscription_test.rs (2 hunks)
Additional comments not posted (5)
crates/torii/graphql/src/tests/subscription_test.rs (5)

118-118: Ohayo sensei! The change looks good to me.

The modification from &keys_str to Some(&keys_str) aligns with the updated function signature for set_entity. Wrapping the keys_str value in an Option should not affect the test behavior.


236-236: Ohayo sensei! The change is consistent with the updated function signature.

Wrapping the keys_str value in an Option when calling set_entity should not impact the test behavior, as the value is still being passed correctly.


Line range hint 259-332: Ohayo sensei! No changes detected in this test function.

As there are no modifications in the test_model_subscription function, I'll skip reviewing it to focus on the updated code segments.


Line range hint 334-406: Ohayo sensei! This test function remains unchanged.

Since there are no alterations in the test_model_subscription_with_id function, I'll move on to reviewing the modified code segments.


Line range hint 408-465: Ohayo sensei! No modifications found in this test function.

The test_event_emitted function has not been altered, so I'll skip reviewing it and focus on the updated code segments instead.


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

codecov bot commented Sep 14, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 4 lines in your changes missing coverage. Please review.

Project coverage is 68.06%. Comparing base (ed2aa83) to head (6a3ed4a).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...s/torii/core/src/processors/store_update_member.rs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2427      +/-   ##
==========================================
+ Coverage   67.91%   68.06%   +0.14%     
==========================================
  Files         364      364              
  Lines       47910    47858      -52     
==========================================
+ Hits        32539    32575      +36     
+ Misses      15371    15283      -88     

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


db.execute().await.unwrap();
// Expect bootstrap_engine to error out due to the existing bug
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// Expect bootstrap_engine to error out due to the existing bug
// Expect bootstrap_engine to not error out

stale comment from when i was trying to see if without the fixes it actually errors out, can be changed to this now

@@ -292,24 +296,31 @@ async fn test_load_from_remote_del() {
db.execute().await.unwrap();
}

// Start of Selection
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// Start of Selection

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.

3 participants