use of li.naska.bgg.repository.model.BggPlaysQueryParams 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())));
}
use of li.naska.bgg.repository.model.BggPlaysQueryParams in project bgg-api by tnaskali.
the class PlaysService method getPlays.
private Mono<List<Play>> getPlays(Supplier<BggPlaysQueryParams> queryParamsSupplier) {
BggPlaysQueryParams firstPageQueryParams = queryParamsSupplier.get();
firstPageQueryParams.setPage(1);
return getPlays(firstPageQueryParams).flatMap(plays -> {
int numPages = (int) Math.ceil((double) plays.getNumplays() / BGG_PLAYS_PAGE_SIZE);
return Flux.range(1, numPages).flatMapSequential(page -> {
if (page == 1) {
return Mono.just(plays);
}
BggPlaysQueryParams queryParams = queryParamsSupplier.get();
queryParams.setPage(page);
return getPlays(queryParams);
}).flatMapIterable(Plays::getPlays).collect(Collectors.toList());
});
}
Aggregations