Skip to content

Commit

Permalink
application snapshot history count logic fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonpoo authored and ludomikula committed Nov 22, 2024
1 parent 138ebd8 commit a28b90f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public interface ApplicationHistorySnapshotService {
Mono<List<ApplicationHistorySnapshotTS>> listAllHistorySnapshotBriefInfoArchived(String applicationId, String compName, String theme, Instant from, Instant to, PageRequest pageRequest);

Mono<Long> countByApplicationId(String applicationId);
Mono<Long> countByApplicationIdArchived(String applicationId);

Mono<ApplicationHistorySnapshot> getHistorySnapshotDetail(String historySnapshotId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ public Mono<Long> countByApplicationId(String applicationId) {
e -> ofException(BizError.FETCH_HISTORY_SNAPSHOT_COUNT_FAILURE, "FETCH_HISTORY_SNAPSHOT_COUNT_FAILURE"));
}

@Override
public Mono<Long> countByApplicationIdArchived(String applicationId) {
return repositoryArchived.countByApplicationId(applicationId)
.onErrorMap(Exception.class,
e -> ofException(BizError.FETCH_HISTORY_SNAPSHOT_COUNT_FAILURE, "FETCH_HISTORY_SNAPSHOT_COUNT_FAILURE"));
}


@Override
public Mono<ApplicationHistorySnapshot> getHistorySnapshotDetail(String historySnapshotId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Mono<ResponseView<Boolean>> create(@RequestBody ApplicationHistorySnapsho

@Override
public Mono<ResponseView<Map<String, Object>>> listAllHistorySnapshotBriefInfo(@PathVariable String applicationId,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam String compName,
@RequestParam String theme,
Expand Down Expand Up @@ -92,7 +92,7 @@ public Mono<ResponseView<Map<String, Object>>> listAllHistorySnapshotBriefInfo(@

@Override
public Mono<ResponseView<Map<String, Object>>> listAllHistorySnapshotBriefInfoArchived(@PathVariable String applicationId,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam String compName,
@RequestParam String theme,
Expand All @@ -119,7 +119,7 @@ public Mono<ResponseView<Map<String, Object>>> listAllHistorySnapshotBriefInfoAr
)
);

Mono<Long> applicationHistorySnapshotCount = applicationHistorySnapshotService.countByApplicationId(applicationId);
Mono<Long> applicationHistorySnapshotCount = applicationHistorySnapshotService.countByApplicationIdArchived(applicationId);

return Mono.zip(snapshotBriefInfoList, applicationHistorySnapshotCount)
.map(tuple -> ImmutableMap.of("list", tuple.getT1(), "count", tuple.getT2()));
Expand Down

0 comments on commit a28b90f

Please sign in to comment.