Skip to content

Commit 0a0f735

Browse files
committed
edit
1 parent 2d81e08 commit 0a0f735

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/main/java/com/catcher/batch/core/service/BatchService.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,19 @@ public void batch(List<? extends ApiResponse> apiResponses) {
3636
List<CatcherItem> catcherItems = apiResponses.stream()
3737
.filter(apiResponse -> {
3838
String hashKey = hashString(apiResponse);
39-
if (itemMap.containsKey(hashKey) && isContentChanged(itemMap.get(hashKey), apiResponse)) {
40-
if (isExpired(apiResponse)) {
39+
if (itemMap.containsKey(hashKey)) {
40+
if (isExpired(apiResponse.getEndAt())) {
4141
deleteItems.add(itemMap.get(hashKey));
4242
itemMap.remove(hashKey);
4343
return false;
4444
}
45+
if (isContentChanged(itemMap.get(hashKey), apiResponse)) {
46+
return true;
47+
}
48+
} else {
49+
if(isExpired(apiResponse.getEndAt())) {
50+
return false;
51+
}
4552
}
4653
return true;
4754
})
@@ -93,7 +100,7 @@ protected CatcherItem apiResponseToCatcherItem(ApiResponse apiResponse, Category
93100
.build();
94101
}
95102

96-
private boolean isExpired(ApiResponse apiResponse) {
97-
return apiResponse.getStartAt() != null && ZonedDateTime.now().isAfter(apiResponse.getStartAt());
103+
private boolean isExpired(ZonedDateTime endDateTime) {
104+
return endDateTime != null && ZonedDateTime.now().isAfter(endDateTime);
98105
}
99106
}

0 commit comments

Comments
 (0)