Skip to content

Commit

Permalink
refactor(queries)!: remove QueryIterator::remaining_in_current_batch …
Browse files Browse the repository at this point in the history
…from public API

Signed-off-by: ⭐️NINIKA⭐️ <[email protected]>
  • Loading branch information
DCNick3 authored and mversic committed Aug 12, 2024
1 parent 73b5acc commit 6ff772d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
31 changes: 22 additions & 9 deletions client/tests/integration/pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,28 @@ fn fetch_size_should_work() -> Result<()> {

register_assets(&client)?;

let iter = client
.query(asset::all_definitions())
.with_pagination(Pagination {
limit: Some(nonzero!(7_u32)),
offset: Some(nonzero!(1_u64)),
})
.with_fetch_size(FetchSize::new(Some(nonzero!(3_u32))))
.execute()?;
assert_eq!(iter.remaining_in_current_batch(), 3);
// use the lower-level API to inspect the batch size
use iroha_data_model::query::{
builder::QueryExecutor as _,
parameters::{FetchSize, QueryParams, Sorting},
QueryWithFilter, QueryWithParams,
};

let query = QueryWithParams::new(
QueryWithFilter::new(asset::all_definitions(), CompoundPredicate::PASS).into(),
QueryParams::new(
Pagination {
limit: Some(nonzero!(7_u32)),
offset: Some(nonzero!(1_u64)),
},
Sorting::default(),
FetchSize::new(Some(nonzero!(3_u32))),
),
);
let (first_batch, _continue_cursor) = client.start_query(query)?;

assert_eq!(first_batch.len(), 3);

Ok(())
}

Expand Down
12 changes: 0 additions & 12 deletions data_model/src/query/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,6 @@ where
}
}

impl<E, T> QueryIterator<E, T>
where
E: QueryExecutor,
{
/// Returns the number of results remaining in the current batch.
///
/// Note that it is NOT the number of results remaining in the query, which is not exposed by iroha API.
pub fn remaining_in_current_batch(&self) -> usize {
self.current_batch_iter.as_slice().len()
}
}

impl<E, T> Iterator for QueryIterator<E, T>
where
E: QueryExecutor,
Expand Down

0 comments on commit 6ff772d

Please sign in to comment.