CronNotScheduled

This commit is contained in:
Gregor Kleen 2018-10-13 22:01:11 +02:00
parent d6e0e9f7ca
commit c3332b57ef
3 changed files with 13 additions and 2 deletions

View File

@ -179,6 +179,9 @@ nextCronMatch tz mPrev now c@Cron{..}
-> MatchAsap
| otherwise
-> MatchAt $ addUTCTime cronMinInterval prevT
CronNotScheduled
| CronTimestamp{ cronTimestamp = localTimeToUTCTZ tz -> ts } <- cronNext
, now <= ts -> MatchAt ts
cronNext -> execRef (addUTCTime cronMinInterval prevT) True cronNext
where
execRef ref wasExecd cronAbsolute = case cronAbsolute of
@ -203,3 +206,4 @@ nextCronMatch tz mPrev now c@Cron{..}
localDay <- maybeToList $ fromGregorianValid (fromIntegral cronYear) (fromIntegral cronMonth) (fromIntegral cronDayOfMonth)
let localTimeOfDay = TimeOfDay (fromIntegral cronHour) (fromIntegral cronMinute) (fromIntegral cronSecond)
return $ localTimeToUTCTZ tz LocalTime{..}
CronNotScheduled -> MatchNone

View File

@ -43,6 +43,7 @@ data CronAbsolute
, cronDayOfWeek
, cronHour, cronMinute, cronSecond :: CronMatch
}
| CronNotScheduled
deriving (Eq, Show, Read)
makeLenses_ ''CronAbsolute

View File

@ -384,13 +384,19 @@ determineCrontab = (\ct -> ct <$ pruneLastExecs ct) <=< execWriterT $ do
(JobCtlQueue $ JobQueueNotification NotificationSheetActive{..})
Cron
{ cronInitial = CronTimestamp $ utcToLocalTimeTZ appTZ sheetActiveFrom
, cronRepeat = Nothing
, cronRepeat = Just CronPeriod
{ cronMinInterval = 3600
, cronNext = CronNotScheduled -- Allow repetition of the notification (if something changes), but wait at least an hour
}
}
tell $ HashMap.singleton
(JobCtlQueue $ JobQueueNotification NotificationSheetInactive{..})
Cron
{ cronInitial = CronTimestamp . utcToLocalTimeTZ appTZ . max sheetActiveFrom $ addUTCTime (-nominalDay) sheetActiveTo
, cronRepeat = Nothing
, cronRepeat = Just CronPeriod
{ cronMinInterval = 3600
, cronNext = CronNotScheduled
}
}
runConduit $ transPipe lift (selectSource [] []) .| C.mapM_ sheetJobs