Skip to content

Commit b0e9367

Browse files
authored
opt(torii-grpc): entity updated after on entities table (#2810)
* opt(torii-grpc): entity updated after on entities table * fix: query * refactor: clean up code and fix total counts * fmt * fmt * clippy
1 parent 8111b6d commit b0e9367

File tree

5 files changed

+152
-86
lines changed

5 files changed

+152
-86
lines changed

crates/torii/core/src/model.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ pub fn build_sql_query(
125125
order_by: Option<&str>,
126126
limit: Option<u32>,
127127
offset: Option<u32>,
128-
internal_updated_at: u64,
129128
) -> Result<(String, String), Error> {
130129
fn collect_columns(table_prefix: &str, path: &str, ty: &Ty, selections: &mut Vec<String>) {
131130
match ty {
@@ -174,7 +173,6 @@ pub fn build_sql_query(
174173
selections.push(format!("{}.id", table_name));
175174
selections.push(format!("{}.keys", table_name));
176175

177-
let mut internal_updated_at_clause = Vec::with_capacity(schemas.len());
178176
// Process each model schema
179177
for model in schemas {
180178
let model_table = model.name();
@@ -183,10 +181,6 @@ pub fn build_sql_query(
183181
[{model_table}].{entity_relation_column}",
184182
));
185183

186-
if internal_updated_at > 0 {
187-
internal_updated_at_clause.push(format!("[{model_table}].internal_updated_at >= ?"));
188-
}
189-
190184
// Collect columns with table prefix
191185
collect_columns(&model_table, "", model, &mut selections);
192186
}
@@ -204,18 +198,6 @@ pub fn build_sql_query(
204198
count_query += &format!(" WHERE {}", where_clause);
205199
}
206200

207-
if !internal_updated_at_clause.is_empty() {
208-
if where_clause.is_none() {
209-
query += " WHERE ";
210-
count_query += " WHERE ";
211-
} else {
212-
query += " AND ";
213-
count_query += " AND ";
214-
}
215-
query += &format!(" {}", internal_updated_at_clause.join(" AND "));
216-
count_query += &format!(" {}", internal_updated_at_clause.join(" AND "));
217-
}
218-
219201
// Use custom order by if provided, otherwise default to event_id DESC
220202
if let Some(order_clause) = order_by {
221203
query += &format!(" ORDER BY {}", order_clause);
@@ -513,7 +495,6 @@ mod tests {
513495
None,
514496
None,
515497
None,
516-
0,
517498
)
518499
.unwrap();
519500

crates/torii/grpc/proto/types.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ message Query {
7676
bool dont_include_hashed_keys = 4;
7777
repeated OrderBy order_by = 5;
7878
repeated string entity_models = 6;
79-
uint64 internal_updated_at = 7;
79+
uint64 entity_updated_after = 7;
8080
}
8181

8282
message EventQuery {

0 commit comments

Comments
 (0)