CronNotScheduled
This commit is contained in:
parent
d6e0e9f7ca
commit
c3332b57ef
@ -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
|
||||
|
||||
@ -43,6 +43,7 @@ data CronAbsolute
|
||||
, cronDayOfWeek
|
||||
, cronHour, cronMinute, cronSecond :: CronMatch
|
||||
}
|
||||
| CronNotScheduled
|
||||
deriving (Eq, Show, Read)
|
||||
|
||||
makeLenses_ ''CronAbsolute
|
||||
|
||||
10
src/Jobs.hs
10
src/Jobs.hs
@ -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
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user