mirror of
https://github.com/YGGverse/btracker.git
synced 2026-03-31 17:15:31 +00:00
implement pagination totals info
This commit is contained in:
parent
3b95561c08
commit
a4ce8e29d5
5 changed files with 38 additions and 20 deletions
|
|
@ -76,9 +76,10 @@ impl Storage {
|
|||
sort_order: Option<(Sort, Order)>,
|
||||
start: Option<usize>,
|
||||
limit: Option<usize>,
|
||||
) -> Result<Vec<Torrent>, String> {
|
||||
) -> Result<(usize, Vec<Torrent>), String> {
|
||||
let f = self.files(sort_order)?;
|
||||
let l = limit.unwrap_or(f.len());
|
||||
let t = f.len();
|
||||
let l = limit.unwrap_or(t);
|
||||
let mut b = Vec::with_capacity(l);
|
||||
for file in f.into_iter().skip(start.unwrap_or_default()).take(l) {
|
||||
if file
|
||||
|
|
@ -163,7 +164,7 @@ impl Storage {
|
|||
.into(),
|
||||
})
|
||||
}
|
||||
Ok(b)
|
||||
Ok((t, b))
|
||||
}
|
||||
|
||||
// Helpers
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue