Skip to content

Commit

Permalink
[#172] refactor(PromotionService): checkAndDeleteInvalidPromotions 성능…
Browse files Browse the repository at this point in the history
… 및 확장성 고려한 refactor
  • Loading branch information
hyerinhwang-sailin committed Aug 16, 2024
1 parent 7d88deb commit 94bf32b
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ public void checkAndDeleteInvalidPromotions() {
List<Promotion> promotions = promotionRepository.findAll();

for (Promotion promotion : promotions) {
if (promotion.getPerformance() != null) {
Performance performance = promotion.getPerformance();
Performance performance = promotion.getPerformance();

List<Schedule> schedules = scheduleRepository.findByPerformanceId(performance.getId());
int minDueDate = scheduleService.getMinDueDate(schedules);
if (performance == null) {
return;
}

List<Schedule> schedules = scheduleRepository.findByPerformanceId(performance.getId());
int minDueDate = scheduleService.getMinDueDate(schedules);

// MinDueDate가 음수일 경우 Promotion 삭제
if (minDueDate < 0) {
promotionRepository.delete(promotion);
}
if (minDueDate < 0) {
promotionRepository.delete(promotion);
}
}
}
Expand Down

0 comments on commit 94bf32b

Please sign in to comment.