Skip to content

Commit

Permalink
Make first non optional and max limit to 100
Browse files Browse the repository at this point in the history
  • Loading branch information
iamvigneshwars committed May 2, 2024
1 parent 4e487fa commit 79ca2a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion charts/datasets/charts/datasets/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ type: application

version: 0.1.0

appVersion: 0.1.0-rc5
appVersion: 0.1.0-rc6
18 changes: 4 additions & 14 deletions datasets/src/graphql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Session {
&self,
ctx: &Context<'_>,
after: Option<String>,
first: Option<u64>,
first: u64,
) -> async_graphql::Result<
Connection<OpaqueCursor<u32>, DataCollection, EmptyFields, EmptyFields>,
> {
Expand All @@ -44,27 +44,17 @@ impl Session {
}
}

let limit = match first {
Some(first) => first + 1,
None => usize::MAX as u64,
};

let limit = first.min(100);
let mut data_collections = query
.limit(limit)
.limit(limit + 1)
.all(database)
.await?
.into_iter()
.map(DataCollection::from)
.collect::<Vec<_>>();

let mut has_next_page = false;

if data_collections.len()
> first
.unwrap_or(usize::MAX.try_into().unwrap())
.try_into()
.unwrap()
{
if data_collections.len() > limit as usize {
has_next_page = true;
data_collections.pop();
}
Expand Down

0 comments on commit 79ca2a7

Please sign in to comment.