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: added historical option for event getters #352

Merged
merged 1 commit into from
Dec 27, 2024

Conversation

rsodre
Copy link
Contributor

@rsodre rsodre commented Dec 9, 2024

Introduced changes

  • added historical option to sdk.getEventMessages() and sdk.subscribeEventQuery()

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added relevant tests
  • Add a dedicated CI job for new examples
  • Performed self-review of the code

Summary by CodeRabbit

  • New Features

    • Added a historical parameter to the getEventMessages and subscribeEventQuery methods, allowing users to specify whether to include historical data in event queries and subscriptions.
    • Enhanced interfaces to support the new historical parameter for subscriptions and entity retrieval.
  • Bug Fixes

    • Updated method signatures to ensure consistent handling of the new parameter across the SDK.
  • Documentation

    • Updated documentation to reflect the addition of the historical parameter in relevant methods.

Copy link

coderabbitai bot commented Dec 9, 2024

Walkthrough

The changes in this pull request introduce a new boolean parameter, historical, with a default value of true, to the getEventMessages, subscribeEventQuery, and related methods in the SDK. This parameter allows for more flexible handling of historical data in event queries and subscriptions. The modifications include updates to method signatures and relevant interfaces, ensuring that the new parameter is consistently integrated across the affected functions without altering existing logic or functionality.

Changes

File Path Change Summary
packages/sdk/src/getEventMessages.ts Added historical parameter to getEventMessages function, replacing hardcoded value.
packages/sdk/src/index.ts Updated subscribeEventQuery and getEventMessages methods to include historical parameter.
packages/sdk/src/subscribeEventQuery.ts Added historical parameter to subscribeEventQuery function, replacing hardcoded value.
packages/sdk/src/types.ts Enhanced SubscribeParams and GetParams interfaces by adding optional historical property.

Possibly related PRs

Suggested reviewers

  • MartianGreed

Poem

In the meadow, where bunnies play,
New features hop in, brightening the day.
With historical tales, we gather and share,
Event messages dance, floating in air.
So let’s celebrate this change, oh so grand,
A leap for our SDK, just as we planned! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 104f8ea and ff2adef.

📒 Files selected for processing (4)
  • packages/sdk/src/getEventMessages.ts (2 hunks)
  • packages/sdk/src/index.ts (3 hunks)
  • packages/sdk/src/subscribeEventQuery.ts (1 hunks)
  • packages/sdk/src/types.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/sdk/src/types.ts
  • packages/sdk/src/index.ts
  • packages/sdk/src/subscribeEventQuery.ts
  • packages/sdk/src/getEventMessages.ts

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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

@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

🧹 Outside diff range and nitpick comments (6)
packages/sdk/src/subscribeEventQuery.ts (1)

39-40: Update JSDoc to document the historical parameter

The historical parameter needs to be documented in the function's JSDoc comments to maintain API documentation completeness.

Add the following to the JSDoc params section:

+ * @param {boolean} [historical=true] - Whether to include historical event messages in the subscription.
packages/sdk/src/getEventMessages.ts (1)

39-40: Update JSDoc to document the historical parameter

The historical parameter needs to be documented in the function's JSDoc comments.

Add the following to the JSDoc params section:

+ * @param {boolean} [historical=true] - Whether to include historical event messages in the query.
packages/sdk/src/index.ts (2)

56-64: Update JSDoc for subscribeEventQuery params

The historical parameter needs to be documented in the method's JSDoc.

Update the params documentation:

 * @param {SubscribeParams<T>} params - Parameters object
+ *        params.historical - Whether to include historical event messages in the subscription

87-103: Update JSDoc for getEventMessages params

The historical parameter needs to be documented in the method's JSDoc.

Update the params documentation:

 * @param {GetParams<T>} params - Parameters object
+ *        params.historical - Whether to include historical event messages in the query
packages/sdk/src/types.ts (2)

359-360: Enhance documentation for the historical parameter.

The comment "historical events" could be more descriptive. Consider adding JSDoc documentation that explains:

  • The parameter's purpose
  • The default value
  • The behavior when true/false
-    // historical events
+    /**
+     * Whether to include historical events in the subscription.
+     * When true (default), includes all past events.
+     * When false, only includes new events from the subscription point.
+     */
     historical?: boolean;

377-378: Enhance documentation for the historical parameter (consistency).

Similar to the SubscribeParams interface, improve the documentation here to maintain consistency across the codebase.

-    // historical events
+    /**
+     * Whether to include historical events in the query results.
+     * When true (default), includes all past events.
+     * When false, only includes new events.
+     */
     historical?: boolean;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0bbfd66 and 12f46ae.

📒 Files selected for processing (4)
  • packages/sdk/src/getEventMessages.ts (2 hunks)
  • packages/sdk/src/index.ts (2 hunks)
  • packages/sdk/src/subscribeEventQuery.ts (1 hunks)
  • packages/sdk/src/types.ts (2 hunks)
🔇 Additional comments (3)
packages/sdk/src/subscribeEventQuery.ts (1)

44-44: LGTM: Historical parameter implementation

The historical parameter is correctly passed to the underlying client method while maintaining backward compatibility with the default true value.

packages/sdk/src/getEventMessages.ts (1)

57-60: LGTM: Historical parameter correctly integrated with pagination

The historical parameter is properly passed to the client method while maintaining the existing pagination logic.

packages/sdk/src/index.ts (1)

Line range hint 56-103: Verify types.ts updates

The AI summary mentions updates to SubscribeParams and GetParams interfaces in types.ts.

Let's verify these type definitions:

✅ Verification successful

Types are correctly defined in types.ts

The historical parameter is properly defined as an optional boolean parameter in the relevant interfaces in types.ts. The code changes are consistent with the type definitions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that types.ts has been updated with the historical parameter

# Check for the historical parameter in interface definitions
rg -A 5 "interface (Subscribe|Get)Params" packages/sdk/src/types.ts

Length of output: 582


Script:

#!/bin/bash
# Let's check for any historical parameter in the entire types.ts file
rg -A 10 "historical[?:]" packages/sdk/src/types.ts

# Also check for any interface that might contain the historical parameter
ast-grep --pattern 'interface $_ {
  $$$
  historical$_
  $$$
}'

Length of output: 467

Comment on lines +359 to +396
// historical events
historical?: boolean;
Copy link

@coderabbitai coderabbitai bot Dec 9, 2024

Choose a reason for hiding this comment

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

💡 Codebase verification

Default value of historical parameter needs to be aligned with the interface

The implementation in both getEventMessages.ts and subscribeEventQuery.ts sets a default value of true for the historical parameter, while the interface in types.ts marks it as optional without a default value. This misalignment should be addressed.

  • packages/sdk/src/getEventMessages.ts: Remove default value true for historical parameter
  • packages/sdk/src/subscribeEventQuery.ts: Remove default value true for historical parameter
🔗 Analysis chain

Verify implementation details across related files.

The interfaces have been updated correctly, but let's verify the implementation details:

Also applies to: 377-378

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the historical parameter

# Check getEventMessages implementation
echo "Checking getEventMessages implementation..."
rg -A 5 "getEventMessages.*=.*async.*" packages/sdk/src/

# Check subscribeEventQuery implementation
echo "Checking subscribeEventQuery implementation..."
rg -A 5 "subscribeEventQuery.*=.*async.*" packages/sdk/src/

# Check for any hardcoded true values that might need to be replaced
echo "Checking for hardcoded historical values..."
rg "historical.*:.*true" packages/sdk/src/

Length of output: 601

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link

Choose a reason for hiding this comment

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

@rsodre, thank you for fixing the issue!


If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!

@rsodre rsodre force-pushed the fetch-events-historical-flag branch from 12f46ae to c3f7328 Compare December 9, 2024 17:46
@rsodre
Copy link
Contributor Author

rsodre commented Dec 27, 2024

@MartianGreed wen merge?

@rsodre rsodre force-pushed the fetch-events-historical-flag branch from 104f8ea to ff2adef Compare December 27, 2024 17:35
@MartianGreed MartianGreed merged commit 85338c4 into dojoengine:main Dec 27, 2024
1 of 2 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.

2 participants