-
Notifications
You must be signed in to change notification settings - Fork 49
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
Raschel sync #2555
Raschel sync #2555
Changes from all commits
e6a0195
3ff0406
4fddc1a
080f8ce
40781d9
c12696d
f6b5866
27aeadd
dc94fac
642dee4
4548342
de96dbf
f44e971
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 |
---|---|---|
|
@@ -136,10 +136,11 @@ export const addMarketSubscription = async <S extends Schema>( | |
await getEntities( | ||
client, | ||
{ | ||
Keys: { | ||
keys: [undefined, undefined], | ||
pattern_matching: "FixedLen", | ||
models: ["s0_eternum-DetachedResource"], | ||
Member: { | ||
model: "s0_eternum-DetachedResource", | ||
member: "resource_amount", | ||
operator: "Gt", | ||
value: { Primitive: { U128: "0" } }, | ||
}, | ||
}, | ||
components, | ||
|
@@ -151,3 +152,72 @@ export const addMarketSubscription = async <S extends Schema>( | |
const end = performance.now(); | ||
console.log("MarketEnd", end - start); | ||
}; | ||
|
||
export const addArrivalsSubscription = async <S extends Schema>( | ||
client: ToriiClient, | ||
components: Component<S, Metadata, undefined>[], | ||
entityIds: number[], | ||
) => { | ||
const start = performance.now(); | ||
console.log("ArrivalsEnd: starting resource arrivals"); | ||
await getEntities( | ||
client, | ||
// todo: waiting on ghlim to check issue with this query | ||
// { | ||
// Composite: { | ||
// operator: "And", | ||
// clauses: [ | ||
// { | ||
// Composite: { | ||
// operator: "Or", | ||
// clauses: entityIds.map((id) => ({ | ||
// Member: { | ||
// model: "s0_eternum-EntityOwner", | ||
// member: "entity_owner_id", | ||
// operator: "Eq", | ||
// value: { Primitive: { U32: id } }, | ||
// }, | ||
// })), | ||
// }, | ||
// }, | ||
// { | ||
// Member: { | ||
// model: "s0_eternum-OwnedResourcesTracker", | ||
// member: "resource_types", | ||
// operator: "Neq", | ||
// value: { Primitive: { U256: "0" } }, | ||
// }, | ||
// }, | ||
// ], | ||
// }, | ||
// }, | ||
Comment on lines
+165
to
+193
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 Based on the gathered evidence, I can now provide a final response: The commented-out query with OwnedResourcesTracker filtering is necessary The codebase analysis reveals that OwnedResourcesTracker is a crucial component used to track resource ownership across the system:
Action items:
🔗 Analysis chainVerify if the simplified query is sufficient The commented-out code shows a more complex query that includes additional filtering for
Let's verify if the simpler query might miss important cases: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check if there are cases where OwnedResourcesTracker is crucial
rg -A 3 "OwnedResourcesTracker" --type typescript
Length of output: 84 Script: #!/bin/bash
# Let's try without file type restriction since the ripgrep version might not support typescript
rg -A 3 "OwnedResourcesTracker"
Length of output: 16197 Script: #!/bin/bash
# Search for any references to resources or tracking in the queries file
rg -A 5 "resource" client/src/dojo/queries.ts
Length of output: 549 Script: #!/bin/bash
# Look for the actual query implementation
ast-grep --pattern 'addArrivalsSubscription($$$)'
Length of output: 197 Script: #!/bin/bash
# Let's look at the actual implementation of addArrivalsSubscription
rg -B 5 -A 10 "export const addArrivalsSubscription" client/src/dojo/queries.ts
Length of output: 529 Script: #!/bin/bash
# Check how OwnedResourcesTracker is used in the codebase
ast-grep --pattern 'NotValue(OwnedResourcesTracker, { resource_types: $_})'
Length of output: 303 |
||
{ | ||
Composite: { | ||
operator: "Or", | ||
clauses: entityIds.map((id) => ({ | ||
Member: { | ||
model: "s0_eternum-EntityOwner", | ||
member: "entity_owner_id", | ||
operator: "Eq", | ||
value: { Primitive: { U32: id } }, | ||
}, | ||
})), | ||
}, | ||
}, | ||
|
||
components, | ||
[], | ||
[ | ||
"s0_eternum-Army", | ||
"s0_eternum-Position", | ||
"s0_eternum-EntityOwner", | ||
"s0_eternum-Weight", | ||
"s0_eternum-OwnedResourcesTracker", | ||
"s0_eternum-ArrivalTime", | ||
], | ||
1000, | ||
false, | ||
); | ||
const end = performance.now(); | ||
console.log("ArrivalsEnd", end - start); | ||
}; |
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.
🛠️ Refactor suggestion
Consider error handling for onComplete callback
The onComplete callback should be protected from errors to prevent queue processing interruption.
📝 Committable suggestion