use of li.naska.bgg.repository.model.BggForumQueryParams 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.repository.model.BggForumQueryParams in project bgg-api by tnaskali.
the class ForumsService method getForum.
public Mono<Forum> getForum(Integer id) {
BggForumQueryParams queryParams = new BggForumQueryParams();
queryParams.setId(id);
return getForum(queryParams);
}
use of li.naska.bgg.repository.model.BggForumQueryParams in project bgg-api by tnaskali.
the class ForumsService method getThreads.
public Mono<List<Thread>> getThreads(Integer id) {
BggForumQueryParams firstPageQueryParams = new BggForumQueryParams();
firstPageQueryParams.setId(id);
firstPageQueryParams.setPage(1);
return getForum(firstPageQueryParams).flatMap(forum -> {
int numPages = (int) Math.ceil((double) forum.getNumthreads() / BGG_FORUM_THREADS_PAGE_SIZE);
return Flux.range(1, numPages).flatMapSequential(page -> {
if (page == 1) {
return Mono.just(forum);
}
BggForumQueryParams queryParams = new BggForumQueryParams();
queryParams.setId(id);
queryParams.setPage(page);
return getForum(queryParams);
}).flatMapIterable(Forum::getThreads).collect(Collectors.toList());
});
}
Aggregations