Package io.meeds.commons.digest.service
Class DigestDueCalculator
java.lang.Object
io.meeds.commons.digest.service.DigestDueCalculator
Answers "is this user due now?" in his own local calendar, in Java and not
in SQL, so that the rule is the same on every database. The rule: the most
recent scheduled occurrence (the send hour of the send day) has passed since
his watermark, and his watermark is not from that occurrence's day already.
Consequences, all wanted: at most one daily digest per local day and one
weekly per local week, always at the send hour or later; a run missed at the
send hour is caught up by the next run; a frequency switched on today sends
its first digest tomorrow; a timezone change never causes a second email the
same local day.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
DigestDueCalculator
public DigestDueCalculator(@Value("${exo.notification.digest.daily.hour:18}") int sendHour, @Value("${exo.notification.digest.weekly.day:FRIDAY}") String weeklyDay)
-
-
Method Details
-
isDue
public boolean isDue(DigestUserEntity user, io.meeds.commons.digest.model.DigestFrequency frequency, Instant now) -
zoneOf
- Parameters:
timeZone- the timezone stored for the user, may be null or unknown- Returns:
- that timezone, or the server one when the user has none (assumption A1 of the specification)
-