Skip to content

Commit

Permalink
Fix collection count offset incorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
Polleps authored and joepio committed Apr 2, 2024
1 parent 8cfdcb2 commit d6c6708
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,24 +255,25 @@ impl Db {

let mut subjects: Vec<String> = vec![];
let mut resources: Vec<Resource> = vec![];
let mut total_count = q.offset;
let mut total_count = 0;

let atoms = self.get_index_iterator_for_query(q);

for (i, atom_res) in atoms.enumerate() {
let atom = atom_res?;

if q.offset > i {
if !q.include_external && !atom.subject.starts_with(&self_url) {
continue;
}

if !q.include_external && !atom.subject.starts_with(&self_url) {
total_count += 1;

if q.offset > i {
continue;
}

if q.limit.is_none() || subjects.len() < q.limit.unwrap() {
if !should_include_resource(q) {
subjects.push(atom.subject.clone());
total_count += 1;
continue;
}

Expand All @@ -282,8 +283,6 @@ impl Db {
resources.push(resource);
}
}

total_count += 1;
}

Ok(QueryResult {
Expand Down

0 comments on commit d6c6708

Please sign in to comment.