diff --git a/src/Jobs/Crontab.hs b/src/Jobs/Crontab.hs index d4a140512..6605f42d5 100644 --- a/src/Jobs/Crontab.hs +++ b/src/Jobs/Crontab.hs @@ -166,10 +166,10 @@ determineCrontab = execWriterT $ do tell $ HashMap.singleton (JobCtlQueue $ JobQueueNotification NotificationSheetActive{..}) Cron - { cronInitial = CronTimestamp $ utcToLocalTimeTZ appTZ aFrom - , cronRepeat = CronRepeatNever + { cronInitial = CronTimestamp . utcToLocalTimeTZ appTZ $ maybe id max sheetVisibleFrom aFrom + , cronRepeat = CronRepeatOnChange , cronRateLimit = appNotificationRateLimit - , cronNotAfter = Right $ maybe CronNotScheduled (CronTimestamp . utcToLocalTimeTZ appTZ) sheetActiveTo + , cronNotAfter = maybe (Left appNotificationExpiration) (Right . CronTimestamp . utcToLocalTimeTZ appTZ) sheetActiveTo } for_ sheetHintFrom $ \hFrom -> maybeT (return ()) $ do guard $ maybe True (\aFrom -> abs (diffUTCTime aFrom hFrom) > 300) sheetActiveFrom @@ -177,10 +177,10 @@ determineCrontab = execWriterT $ do tell $ HashMap.singleton (JobCtlQueue $ JobQueueNotification NotificationSheetHint{..}) Cron - { cronInitial = CronTimestamp $ utcToLocalTimeTZ appTZ hFrom - , cronRepeat = CronRepeatNever + { cronInitial = CronTimestamp . utcToLocalTimeTZ appTZ $ maybe id max sheetVisibleFrom hFrom + , cronRepeat = CronRepeatOnChange , cronRateLimit = appNotificationRateLimit - , cronNotAfter = Right CronNotScheduled + , cronNotAfter = Left appNotificationExpiration } for_ sheetSolutionFrom $ \hFrom -> maybeT (return ()) $ do guard $ maybe True (\aFrom -> abs (diffUTCTime aFrom hFrom) > 300) sheetActiveFrom @@ -188,16 +188,16 @@ determineCrontab = execWriterT $ do tell $ HashMap.singleton (JobCtlQueue $ JobQueueNotification NotificationSheetSolution{..}) Cron - { cronInitial = CronTimestamp $ utcToLocalTimeTZ appTZ hFrom - , cronRepeat = CronRepeatNever + { cronInitial = CronTimestamp . utcToLocalTimeTZ appTZ $ maybe id max sheetVisibleFrom hFrom + , cronRepeat = CronRepeatOnChange , cronRateLimit = appNotificationRateLimit - , cronNotAfter = Right CronNotScheduled + , cronNotAfter = Left appNotificationExpiration } for_ sheetActiveTo $ \aTo -> do tell $ HashMap.singleton (JobCtlQueue $ JobQueueNotification NotificationSheetSoonInactive{..}) Cron - { cronInitial = CronTimestamp . utcToLocalTimeTZ appTZ . maybe id max sheetActiveFrom $ addUTCTime (-nominalDay) aTo + { cronInitial = CronTimestamp . utcToLocalTimeTZ appTZ . maybe id max sheetActiveFrom . maybe id max sheetVisibleFrom $ addUTCTime (-nominalDay) aTo , cronRepeat = CronRepeatOnChange -- Allow repetition of the notification (if something changes), but wait at least an hour , cronRateLimit = appNotificationRateLimit , cronNotAfter = Right . CronTimestamp $ utcToLocalTimeTZ appTZ aTo @@ -205,7 +205,7 @@ determineCrontab = execWriterT $ do tell $ HashMap.singleton (JobCtlQueue $ JobQueueNotification NotificationSheetInactive{..}) Cron - { cronInitial = CronTimestamp $ utcToLocalTimeTZ appTZ aTo + { cronInitial = CronTimestamp . utcToLocalTimeTZ appTZ $ maybe id max sheetVisibleFrom aTo , cronRepeat = CronRepeatOnChange , cronRateLimit = appNotificationRateLimit , cronNotAfter = Left appNotificationExpiration