From 31fe447112b6b3d76b0612df91f3eca2e47f2961 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Fri, 18 Oct 2024 10:42:13 +0200 Subject: Use only one position per user --- src/graphql/query.rs | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'src/graphql/query.rs') diff --git a/src/graphql/query.rs b/src/graphql/query.rs index 9e6e0c3..2ab26ec 100644 --- a/src/graphql/query.rs +++ b/src/graphql/query.rs @@ -46,43 +46,25 @@ impl Query { user::query::get_user_by_id(ctx, id).await } - /// Returns all the positions + /// Returns all the positions. It is restricted to admins only. /// /// Request example: /// ```text /// curl http://localhost:8000/graphql /// -H 'authorization: Bearer ***' /// -H 'content-type: application/json' - /// -d '{"query":"{positions {id, userId, createdAt, latitude, longitude, movingActivity}}"}' + /// -d '{"query":"{positions(movingActivity: IN_VEHICLE) {id, userId, createdAt, latitude, longitude, movingActivity}}"}' /// ``` async fn positions<'ctx>( - &self, - ctx: &Context<'ctx>, - #[graphql(desc = "Filter by user id")] user_id: Option, - #[graphql(desc = "Limit results")] limit: Option, - #[graphql(desc = "Offset results")] offset: Option, - ) -> Result>, AppError> { - position::query::get_positions(ctx, user_id, limit, offset).await - } - - /// Returns all the last positions for each user. - /// It is restricted to only admin users. - /// - /// Request example: - /// ```text - /// curl http://localhost:8000/graphql - /// -H 'authorization: Bearer ***' - /// -H 'content-type: application/json' - /// -d '{"query":"lastPositions(movingActivity: IN_VEHICLE) {id, userId, createdAt, latitude, longitude, movingActivity}}"}' - /// ``` - async fn last_positions<'ctx>( &self, ctx: &Context<'ctx>, #[graphql(desc = "Filter by moving activity")] moving_activity: Option< position::MovingActivity, >, + #[graphql(desc = "Limit results")] limit: Option, + #[graphql(desc = "Offset results")] offset: Option, ) -> Result>, AppError> { - position::query::last_positions(ctx, moving_activity).await + position::query::get_positions(ctx, moving_activity, limit, offset).await } /// Returns all the positions -- cgit v1.2.3-18-g5258