diff --git a/src/main/java/clap/server/adapter/outbound/infrastructure/elastic/TaskDocumentAdapter.java b/src/main/java/clap/server/adapter/outbound/infrastructure/elastic/TaskDocumentAdapter.java index 1bf2335d..17956cb2 100644 --- a/src/main/java/clap/server/adapter/outbound/infrastructure/elastic/TaskDocumentAdapter.java +++ b/src/main/java/clap/server/adapter/outbound/infrastructure/elastic/TaskDocumentAdapter.java @@ -149,7 +149,8 @@ private NativeQuery buildSubCategoryTaskRequestQuery(PeriodConfig config, String .withQuery(q -> q .term(v -> v .field("main_category") - .value(mainCategory))).build(); + .value(mainCategory))) + .build(); return NativeQuery.builder() .withQuery(q -> q @@ -164,7 +165,7 @@ private NativeQuery buildSubCategoryTaskRequestQuery(PeriodConfig config, String } private NativeQuery buildManagerTaskProcessQuery(PeriodConfig config) { - return NativeQuery.builder() + NativeQuery rangeQuery = NativeQuery.builder() .withQuery(q -> q .range(r -> r .date(d -> d @@ -172,6 +173,19 @@ private NativeQuery buildManagerTaskProcessQuery(PeriodConfig config) { .timeZone(TIME_ZONE) .gte(String.valueOf(LocalDate.now().minusDays(config.getDaysToSubtract()))) .lt(String.valueOf(LocalDate.now()))))) + .build(); + NativeQuery statusQuery = NativeQuery.builder() + .withQuery(q -> q + .term(v -> v + .field("status") + .value("completed"))) + .build(); + + return NativeQuery.builder() + .withQuery(q -> q + .bool(b -> b + .must(rangeQuery.getQuery(), statusQuery.getQuery())) + ) .withAggregation("manager_task", AggregationBuilders.terms() .field("processor") .build()._toAggregation())