purneLastExecs
This commit is contained in:
parent
27dfae1345
commit
b25bf48821
12
src/Jobs.hs
12
src/Jobs.hs
@ -334,10 +334,19 @@ setSerializable act = setSerializable' (0 :: Integer)
|
|||||||
(\e -> $logWarnS "SQL" (tshow e) *> threadDelay (1e3 * 2 ^ logBackoff) *> setSerializable' (succ logBackoff))
|
(\e -> $logWarnS "SQL" (tshow e) *> threadDelay (1e3 * 2 ^ logBackoff) *> setSerializable' (succ logBackoff))
|
||||||
act'
|
act'
|
||||||
|
|
||||||
|
pruneLastExecs :: Crontab JobCtl -> DB ()
|
||||||
|
pruneLastExecs crontab = runConduit $ selectSource [] [] .| C.mapM_ ensureCrontab
|
||||||
|
where
|
||||||
|
ensureCrontab (Entity leId CronLastExec{..})
|
||||||
|
| Just job <- Aeson.parseMaybe parseJSON cronLastExecJob
|
||||||
|
, HashMap.member (JobCtlQueue job) crontab
|
||||||
|
= return ()
|
||||||
|
| otherwise = delete leId
|
||||||
|
|
||||||
|
|
||||||
determineCrontab :: DB (Crontab JobCtl)
|
determineCrontab :: DB (Crontab JobCtl)
|
||||||
-- ^ Extract all future jobs from the database (sheet deadlines, ...)
|
-- ^ Extract all future jobs from the database (sheet deadlines, ...)
|
||||||
determineCrontab = execWriterT $ do
|
determineCrontab = (\ct -> ct <$ pruneLastExecs ct) <=< execWriterT $ do
|
||||||
AppSettings{..} <- getsYesod appSettings
|
AppSettings{..} <- getsYesod appSettings
|
||||||
|
|
||||||
case appJobFlushInterval of
|
case appJobFlushInterval of
|
||||||
@ -377,7 +386,6 @@ determineCrontab = execWriterT $ do
|
|||||||
{ cronInitial = CronTimestamp . utcToLocalTimeTZ appTZ . max sheetActiveFrom $ addUTCTime (-nominalDay) sheetActiveTo
|
{ cronInitial = CronTimestamp . utcToLocalTimeTZ appTZ . max sheetActiveFrom $ addUTCTime (-nominalDay) sheetActiveTo
|
||||||
, cronRepeat = Nothing
|
, cronRepeat = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
runConduit $ transPipe lift (selectSource [] []) .| C.mapM_ sheetJobs
|
runConduit $ transPipe lift (selectSource [] []) .| C.mapM_ sheetJobs
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user