Skip to content

Commit

Permalink
fix maxSignal
Browse files Browse the repository at this point in the history
  • Loading branch information
noemil12 committed Nov 24, 2023
1 parent 0d9def1 commit b0a6e36
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ public Mono<ResponseEntity<PaginationSignal>> getRequest(String eserviceId, Long
.zipWhen(principalAgreement -> this.signalService.counter(eserviceId))
.flatMap(principalAndCounter -> {
var principal= principalAndCounter.getT1();
var finalStatus = finalSize < principalAndCounter.getT2() ? HttpStatus.PARTIAL_CONTENT : HttpStatus.OK;
var finalStatus = (finalSize+signalId) < principalAndCounter.getT2() ? HttpStatus.PARTIAL_CONTENT : HttpStatus.OK;
return this.signalService.pullSignal(principal.getPrincipalId(), eserviceId, signalId, finalSize)
.collectList()
.map(list -> ResponseEntity.status(finalStatus)
.body(toPagination(list)));
.body(toPagination(list, principalAndCounter.getT2())));
});
}


private PaginationSignal toPagination(List<Signal> list) {
private PaginationSignal toPagination(List<Signal> list, Integer maxSignalId ) {
PaginationSignal paginationSignal = new PaginationSignal();
paginationSignal.setSignals(list);
if (list == null || list.isEmpty()) paginationSignal.setLastSignalId(null);
if (list == null || list.isEmpty()) paginationSignal.setLastSignalId(maxSignalId.longValue()-1);
else {
paginationSignal.setLastSignalId(list.get(list.size()-1).getSignalId());
}
Expand Down

0 comments on commit b0a6e36

Please sign in to comment.