use of li.naska.bgg.util.PagingHelper in project bgg-api by tnaskali.
the class ForumsService method getPagedThreads.
public Mono<Page<Thread>> getPagedThreads(Integer id, PagingParams pagingParams) {
PagingHelper helper = new PagingHelper(pagingParams.getSize(), pagingParams.getPage(), BGG_FORUM_THREADS_PAGE_SIZE);
BggForumQueryParams firstPageQueryParams = new BggForumQueryParams();
firstPageQueryParams.setId(id);
firstPageQueryParams.setPage(helper.getBggStartPage());
return getForum(firstPageQueryParams).flatMap(forum -> helper.getBggPagesRange(forum.getNumthreads()).flatMapSequential(page -> {
if (page == helper.getBggStartPage()) {
return Mono.just(forum);
}
BggForumQueryParams queryParams = new BggForumQueryParams();
queryParams.setId(id);
queryParams.setPage(page);
return getForum(queryParams);
}).flatMapIterable(Forum::getThreads).collect(Collectors.toList()).map(list -> helper.buildPage(list, forum.getNumthreads())));
}
use of li.naska.bgg.util.PagingHelper 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.util.PagingHelper in project bgg-api by tnaskali.
the class ThingsService method getPagedComments.
public Mono<Page<Comment>> getPagedComments(Integer id, PagingParams pagingParams) {
PagingHelper helper = new PagingHelper(pagingParams.getSize(), pagingParams.getPage(), BGG_THING_COMMENTS_PAGE_SIZE);
BggThingsQueryParams firstPageQueryParams = new BggThingsQueryParams();
firstPageQueryParams.setId(id.toString());
firstPageQueryParams.setComments(1);
firstPageQueryParams.setPage(helper.getBggStartPage());
firstPageQueryParams.setPagesize(BGG_THING_COMMENTS_PAGE_SIZE);
return getThing(firstPageQueryParams).flatMap(thing -> helper.getBggPagesRange(thing.getNumcomments()).flatMapSequential(page -> {
BggThingsQueryParams queryParams = new BggThingsQueryParams();
queryParams.setId(id.toString());
queryParams.setComments(1);
queryParams.setPage(page);
queryParams.setPagesize(BGG_THING_COMMENTS_PAGE_SIZE);
return getThing(queryParams);
}).flatMapIterable(Thing::getComments).collect(Collectors.toList()).map(list -> helper.buildPage(list, thing.getNumcomments())));
}
use of li.naska.bgg.util.PagingHelper in project bgg-api by tnaskali.
the class ThingsService method getPagedRatings.
public Mono<Page<Comment>> getPagedRatings(Integer id, PagingParams pagingParams) {
PagingHelper helper = new PagingHelper(pagingParams.getSize(), pagingParams.getPage(), BGG_THING_COMMENTS_PAGE_SIZE);
BggThingsQueryParams firstPageQueryParams = new BggThingsQueryParams();
firstPageQueryParams.setId(id.toString());
firstPageQueryParams.setRatingcomments(1);
firstPageQueryParams.setPage(helper.getBggStartPage());
firstPageQueryParams.setPagesize(BGG_THING_COMMENTS_PAGE_SIZE);
return getThing(firstPageQueryParams).flatMap(thing -> helper.getBggPagesRange(thing.getNumcomments()).flatMapSequential(page -> {
BggThingsQueryParams queryParams = new BggThingsQueryParams();
queryParams.setId(id.toString());
queryParams.setRatingcomments(1);
queryParams.setPage(page);
queryParams.setPagesize(BGG_THING_COMMENTS_PAGE_SIZE);
return getThing(queryParams);
}).flatMapIterable(Thing::getComments).collect(Collectors.toList()).map(list -> helper.buildPage(list, thing.getNumcomments())));
}
use of li.naska.bgg.util.PagingHelper in project bgg-api by tnaskali.
the class UsersService method getPagedBuddies.
public Mono<Page<Buddy>> getPagedBuddies(String username, PagingParams pagingParams) {
PagingHelper helper = new PagingHelper(pagingParams.getSize(), pagingParams.getPage(), BGG_USER_BUDDIES_PAGE_SIZE);
BggUserQueryParams firstPageQueryParams = new BggUserQueryParams();
firstPageQueryParams.setName(username);
firstPageQueryParams.setBuddies(1);
firstPageQueryParams.setPage(helper.getBggStartPage());
return getUser(firstPageQueryParams).flatMap(user -> helper.getBggPagesRange(user.getNumbuddies()).flatMapSequential(page -> {
if (page == helper.getBggStartPage()) {
return Mono.just(user);
}
BggUserQueryParams queryParams = new BggUserQueryParams();
queryParams.setName(username);
queryParams.setBuddies(1);
queryParams.setPage(page);
return getUser(queryParams);
}).flatMapIterable(User::getBuddies).collect(Collectors.toList()).map(list -> helper.buildPage(list, user.getNumbuddies())));
}
Aggregations