Skip to content

Commit

Permalink
Fix unnecessary request in sync pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
thirteenowls committed May 23, 2024
1 parent 4a4f704 commit 864a781
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/clients/pagination/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@ where
}

match (self.req)(self.page_size, self.offset) {
Ok(page) if page.items.is_empty() => {
self.done = true;
None
}
Ok(page) => {
self.offset += page.items.len() as u32;
Some(Ok(page))
if page.next.is_none() {
self.done = true;
}

if page.items.is_empty() {
None
} else {
self.offset += page.items.len() as u32;
Some(Ok(page))
}
}
Err(e) => Some(Err(e)),
}
Expand Down

0 comments on commit 864a781

Please sign in to comment.