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

Feat(torii-grpc): Add total_count on RetrieveEntitiesResponse #1545

Merged
merged 4 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/torii/client/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@
/// type of entites matching keys and/or models.
pub async fn entities(&self, query: Query) -> Result<Vec<Entity>, Error> {
let mut grpc_client = self.inner.write().await;
let RetrieveEntitiesResponse { entities } = grpc_client.retrieve_entities(query).await?;
let RetrieveEntitiesResponse { entities, total_count: _ } =
grpc_client.retrieve_entities(query).await?;

Check warning on line 162 in crates/torii/client/src/client/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/client/src/client/mod.rs#L161-L162

Added lines #L161 - L162 were not covered by tests
Ok(entities.into_iter().map(TryInto::try_into).collect::<Result<Vec<Entity>, _>>()?)
}

Expand Down
1 change: 1 addition & 0 deletions crates/torii/grpc/proto/world.proto
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ message RetrieveEntitiesRequest {

message RetrieveEntitiesResponse {
repeated types.Entity entities = 1;
uint32 total_count = 2;
}
3 changes: 2 additions & 1 deletion crates/torii/grpc/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,9 @@
}
}
};
let total_count = entities.len() as u32;

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

View check run for this annotation

Codecov / codecov/patch

crates/torii/grpc/src/server/mod.rs#L411

Added line #L411 was not covered by tests
broody marked this conversation as resolved.
Show resolved Hide resolved

Ok(RetrieveEntitiesResponse { entities })
Ok(RetrieveEntitiesResponse { entities, total_count })

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

View check run for this annotation

Codecov / codecov/patch

crates/torii/grpc/src/server/mod.rs#L413

Added line #L413 was not covered by tests
}

fn map_row_to_entity(row: &SqliteRow, schemas: &[Ty]) -> Result<proto::types::Entity, Error> {
Expand Down
2 changes: 1 addition & 1 deletion crates/torii/types-test/Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ source = "git+https://github.com/dojoengine/dojo?tag=v0.3.11#1e651b5d4d3b79b14a7

[[package]]
name = "types_test"
version = "0.5.0"
version = "0.5.1"
dependencies = [
"dojo",
]
2 changes: 1 addition & 1 deletion examples/spawn-and-move/Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies = [

[[package]]
name = "dojo_examples"
version = "0.5.0"
version = "0.5.1"
dependencies = [
"dojo",
]
Expand Down
Loading