Skip to content

Commit

Permalink
fix timestamp issue
Browse files Browse the repository at this point in the history
  • Loading branch information
edisontim committed Dec 14, 2024
1 parent 04b2764 commit 85df91a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 1 addition & 2 deletions crates/torii/core/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ pub fn build_sql_query(
));

if internal_updated_at > 0 {
internal_updated_at_clause
.push(format!("[{model_table}].internal_updated_at > {}", internal_updated_at));
internal_updated_at_clause.push(format!("[{model_table}].internal_updated_at > ?"));

Check warning on line 187 in crates/torii/core/src/model.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/core/src/model.rs#L187

Added line #L187 was not covered by tests
}

// Collect columns with table prefix
Expand Down
12 changes: 11 additions & 1 deletion crates/torii/grpc/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use proto::world::{
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use sqlx::prelude::FromRow;
use sqlx::sqlite::SqliteRow;
use sqlx::types::chrono::{DateTime, Utc};
use sqlx::{Pool, Row, Sqlite};
use starknet::core::types::Felt;
use starknet::providers::jsonrpc::HttpTransport;
Expand Down Expand Up @@ -361,7 +362,16 @@ impl DojoWorld {
internal_updated_at,
)?;

let query = sqlx::query(&entity_query).bind(models_str);
let mut query = sqlx::query(&entity_query).bind(models_str);
if internal_updated_at > 0 {
for _ in 0..schemas.len() {
query = query.bind(
DateTime::<Utc>::from_timestamp(internal_updated_at as i64, 0)
.ok_or_else(|| Error::from(QueryError::UnsupportedQuery))?
.to_rfc3339(),

Check warning on line 371 in crates/torii/grpc/src/server/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/grpc/src/server/mod.rs#L367-L371

Added lines #L367 - L371 were not covered by tests
);
}
}
let rows = query.fetch_all(&mut *tx).await?;
let schemas = Arc::new(schemas);

Expand Down

0 comments on commit 85df91a

Please sign in to comment.