-
Notifications
You must be signed in to change notification settings - Fork 54
feat: allow passing historical as a parameter #313
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,7 @@ export const getSyncEntities = async <S extends Schema>( | |
* @param entityKeyClause - An array of entity key clauses to synchronize. | ||
* @param limit - The maximum number of events to fetch per request (default: 100). | ||
* @param logging - Whether to log debug information (default: false). | ||
* @param historical - Whether to fetch and subscribe to historical events (default: true). | ||
* @returns A promise that resolves to a subscription for event updates. | ||
* | ||
* @example | ||
|
@@ -89,11 +90,18 @@ export const getSyncEvents = async <S extends Schema>( | |
clause: Clause | undefined, | ||
entityKeyClause: EntityKeysClause[], | ||
limit: number = 100, | ||
logging: boolean = false | ||
logging: boolean = false, | ||
historical: boolean = true | ||
) => { | ||
if (logging) console.log("Starting getSyncEvents"); | ||
await getEvents(client, components, limit, clause, logging); | ||
return await syncEvents(client, components, entityKeyClause, logging); | ||
await getEvents(client, components, limit, clause, logging, historical); | ||
return await syncEvents( | ||
client, | ||
components, | ||
entityKeyClause, | ||
logging, | ||
historical | ||
); | ||
}; | ||
|
||
/** | ||
|
@@ -150,13 +158,15 @@ export const getEntities = async <S extends Schema>( | |
* @param limit - The maximum number of event messages to fetch per request (default: 100). | ||
* @param clause - An optional clause to filter event messages. | ||
* @param logging - Whether to log debug information (default: false). | ||
* @param historical - Whether to fetch historical events (default: true). | ||
*/ | ||
export const getEvents = async <S extends Schema>( | ||
client: ToriiClient, | ||
components: Component<S, Metadata, undefined>[], | ||
limit: number = 100, | ||
clause: Clause | undefined, | ||
logging: boolean = false | ||
logging: boolean = false, | ||
historical: boolean = true | ||
) => { | ||
if (logging) console.log("Starting getEvents"); | ||
let offset = 0; | ||
|
@@ -170,7 +180,7 @@ export const getEvents = async <S extends Schema>( | |
clause, | ||
dont_include_hashed_keys: false, | ||
}, | ||
true | ||
historical | ||
); | ||
|
||
if (logging) console.log("entities", entities); | ||
|
@@ -291,6 +301,7 @@ export const syncEntities = async <S extends Schema>( | |
* @param components - An array of component definitions. | ||
* @param entityKeyClause - An array of EntityKeysClause to filter entities. | ||
* @param logging - Whether to log debug information (default: false). | ||
* @param historical - Whether to sync to historical events (default: true). | ||
* @returns A promise that resolves with the subscription handler. | ||
* @example | ||
* const sync = await syncEvents(client, components, entityKeyClause); | ||
|
@@ -301,12 +312,13 @@ export const syncEvents = async <S extends Schema>( | |
client: ToriiClient, | ||
components: Component<S, Metadata, undefined>[], | ||
entityKeyClause: EntityKeysClause[], | ||
logging: boolean = false | ||
logging: boolean = false, | ||
historical: boolean = true | ||
Comment on lines
+315
to
+316
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Verification needed: Historical parameter implementation mismatch The implementation shows inconsistency in how the
This suggests potential issues:
🔗 Analysis chainLGTM: Implementation correctly uses the historical parameter. The changes properly integrate with the client's API. However, let's verify the client's implementation supports this parameter. Also applies to: 321-321 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify ToriiClient's onEventMessageUpdated method supports the historical parameter
# Test: Search for the onEventMessageUpdated method definition
ast-grep --pattern 'interface ToriiClient {
$$$
onEventMessageUpdated($_): $_
$$$
}'
Length of output: 92 Script: #!/bin/bash
# Let's try a broader search for ToriiClient and onEventMessageUpdated
# First, find relevant files
fd -t f -e ts -e tsx ToriiClient
# Then search for onEventMessageUpdated method/function definitions
rg -l "onEventMessageUpdated"
# Finally, let's look for actual implementations or interface definitions
ast-grep --pattern 'onEventMessageUpdated($_)'
Length of output: 186 Script: #!/bin/bash
# Let's examine the actual implementation and usage in both files
rg -A 5 -B 5 "onEventMessageUpdated" packages/sdk/src/subscribeEventQuery.ts packages/state/src/recs/index.ts
Length of output: 1657 |
||
) => { | ||
if (logging) console.log("Starting syncEvents"); | ||
return await client.onEventMessageUpdated( | ||
entityKeyClause, | ||
true, | ||
historical, | ||
(fetchedEntities: any, data: any) => { | ||
if (logging) console.log("Event message updated", fetchedEntities); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests needed for the new historical parameter functionality.
While the implementation looks good, tests should be added to verify the behavior of the
historical
parameter across all modified functions. This should include:historical=true
(default behavior)historical=false
(new behavior)Would you like me to help create test cases for these scenarios?
Also applies to: 168-169, 315-316