use of li.naska.bgg.resource.v3.model.Play in project bgg-api by tnaskali.
the class PlaysService method getPagedPlays.
private Mono<Page<Play>> getPagedPlays(Supplier<BggPlaysQueryParams> queryParamsSupplier, PagingParams pagingParams) {
PagingHelper helper = new PagingHelper(pagingParams.getSize(), pagingParams.getPage(), BGG_PLAYS_PAGE_SIZE);
BggPlaysQueryParams firstPageQueryParams = queryParamsSupplier.get();
firstPageQueryParams.setPage(helper.getBggStartPage());
return getPlays(firstPageQueryParams).flatMap(plays -> helper.getBggPagesRange(plays.getNumplays()).flatMapSequential(page -> {
if (page == helper.getBggStartPage()) {
return Mono.just(plays);
}
BggPlaysQueryParams queryParams = queryParamsSupplier.get();
queryParams.setPage(page);
return getPlays(queryParams);
}).flatMapIterable(Plays::getPlays).collect(Collectors.toList()).map(list -> helper.buildPage(list, plays.getNumplays())));
}
Aggregations