Skip to content

Commit 06bf533

Browse files
committed
CLAP-342 Fix : 담당자별 처리량 완료인것만 가져오도록 쿼리수정
<footer> - 관련: #441
1 parent 2e50c4a commit 06bf533

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/main/java/clap/server/adapter/outbound/infrastructure/elastic/TaskDocumentAdapter.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ private NativeQuery buildSubCategoryTaskRequestQuery(PeriodConfig config, String
149149
.withQuery(q -> q
150150
.term(v -> v
151151
.field("main_category")
152-
.value(mainCategory))).build();
152+
.value(mainCategory)))
153+
.build();
153154

154155
return NativeQuery.builder()
155156
.withQuery(q -> q
@@ -164,14 +165,27 @@ private NativeQuery buildSubCategoryTaskRequestQuery(PeriodConfig config, String
164165
}
165166

166167
private NativeQuery buildManagerTaskProcessQuery(PeriodConfig config) {
167-
return NativeQuery.builder()
168+
NativeQuery rangeQuery = NativeQuery.builder()
168169
.withQuery(q -> q
169170
.range(r -> r
170171
.date(d -> d
171172
.field("created_at")
172173
.timeZone(TIME_ZONE)
173174
.gte(String.valueOf(LocalDate.now().minusDays(config.getDaysToSubtract())))
174175
.lt(String.valueOf(LocalDate.now())))))
176+
.build();
177+
NativeQuery statusQuery = NativeQuery.builder()
178+
.withQuery(q -> q
179+
.term(v -> v
180+
.field("status")
181+
.value("completed")))
182+
.build();
183+
184+
return NativeQuery.builder()
185+
.withQuery(q -> q
186+
.bool(b -> b
187+
.must(rangeQuery.getQuery(), statusQuery.getQuery()))
188+
)
175189
.withAggregation("manager_task", AggregationBuilders.terms()
176190
.field("processor")
177191
.build()._toAggregation())

0 commit comments

Comments
 (0)