fixed empty advertising
This commit is contained in:
@@ -39,7 +39,8 @@ public class AdvertisingController {
|
|||||||
log.info("getNextAdvertising");
|
log.info("getNextAdvertising");
|
||||||
Optional<SelectedAdvertisingDto> selected = advertisingSelectionService.selectAdvertising(authentication, sessionId, request);
|
Optional<SelectedAdvertisingDto> selected = advertisingSelectionService.selectAdvertising(authentication, sessionId, request);
|
||||||
if (selected.isEmpty()) {
|
if (selected.isEmpty()) {
|
||||||
log.warn("failed get advertising");
|
// Нормальная ситуация (нет активных реклам / кулдаун / кап) — не ошибка
|
||||||
|
log.debug("No advertising to show, returning 204");
|
||||||
return ResponseEntity.noContent().build();
|
return ResponseEntity.noContent().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ public class AdvertisingSelectionService {
|
|||||||
String resolvedSessionId = sessionId != null ? sessionId : request.getSession(true).getId();
|
String resolvedSessionId = sessionId != null ? sessionId : request.getSession(true).getId();
|
||||||
|
|
||||||
if (!frequencyService.isSessionCooldownPassed(resolvedSessionId)) {
|
if (!frequencyService.isSessionCooldownPassed(resolvedSessionId)) {
|
||||||
log.warn("isSessionCooldownPassed by {} resolvedSessionId is empty", resolvedSessionId);
|
log.debug("Session cooldown not passed for sessionId={}", resolvedSessionId);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Advertising> eligible = adRepository.findEligibleAds(LocalDateTime.now());
|
List<Advertising> eligible = adRepository.findEligibleAds(LocalDateTime.now());
|
||||||
if (eligible.isEmpty()) {
|
if (eligible.isEmpty()) {
|
||||||
log.warn("findEligibleAds is empty");
|
log.debug("No eligible ads to show");
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user