From 1ae2cd0846b6e88074052c32bbf901f0abb8d7cf Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Wed, 13 Apr 2022 14:27:07 +0200 Subject: [PATCH] chore(lms): activate qualfication job in crontab --- config/settings.yml | 2 +- src/Jobs/Crontab.hs | 16 +++++++++------- src/Jobs/Handler/LMS.hs | 2 +- src/Jobs/Handler/QueueNotification.hs | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/config/settings.yml b/config/settings.yml index 7f51c53af..d0fdf099d 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -68,7 +68,7 @@ synchronise-ldap-users-interval: "_env:SYNCHRONISE_LDAP_INTERVAL:3600" study-features-recache-relevance-within: 172800 study-features-recache-relevance-interval: 293 -qualification-check: 28800 +qualification-check: 3 log-settings: detailed: "_env:DETAILED_LOGGING:false" diff --git a/src/Jobs/Crontab.hs b/src/Jobs/Crontab.hs index 9214d50b6..97e6052c6 100644 --- a/src/Jobs/Crontab.hs +++ b/src/Jobs/Crontab.hs @@ -360,16 +360,18 @@ determineCrontab = execWriterT $ do , cronRateLimit = appStudyFeaturesRecacheRelevanceInterval , cronNotAfter = Right . CronTimestamp . utcToLocalTimeTZ appTZ $ addUTCTime appStudyFeaturesRecacheRelevanceInterval nextIntervalTime } -{- - whenIsJust appQualificationChecks $ \cInterval -> tell $ HashMap.singleton + + whenIsJust appQualificationCheck $ \_ -> tell $ HashMap.singleton (JobCtlQueue JobLmsQualifications) Cron - { cronInitial = CronAsap - , cronRepeat = CronRepeatScheduled . CronCalendar $ cronCalendarAny {} - , cronRateLimit = TODO: CONTINUE HERE - , cronNotAfter = + { cronInitial = CronAsap -- time after scheduling + , cronRepeat = CronRepeatScheduled $ cronCalendarAny { cronHour = cronMatchOne 3 -- cronHour = CronMatchSome (impureNonNull $ Set.fromList [3,15] ) + , cronMinute = cronMatchOne 1 + , cronSecond = cronMatchOne 0 + } + , cronRateLimit = nominalDay / 2 -- minimal time between two executions, before the second job is skipped + , cronNotAfter = Left nominalDay -- maximal delay of an execution, before it is skipped entirely } --} let correctorNotifications :: Map (UserId, SheetId) (Max UTCTime) -> WriterT (Crontab JobCtl) (ReaderT SqlReadBackend (HandlerFor UniWorX)) () diff --git a/src/Jobs/Handler/LMS.hs b/src/Jobs/Handler/LMS.hs index 351a70de4..fff6a9d14 100644 --- a/src/Jobs/Handler/LMS.hs +++ b/src/Jobs/Handler/LMS.hs @@ -32,7 +32,7 @@ dispatchJobLmsQualifications = JobHandlerAtomic act -- E.&&. q E.^. QualificationElearningStart -- checked later, since we need to send out notifications regardless pure $ q E.^. QualificationId forM_ qids $ \(E.unValue -> qid) -> do - $logInfoS "lms" $ "Start e-learning for qualification " <> tshow qid <> "." + $logInfoS "lms" $ "Start e-learning for qualification " <> tshow qid <> "." queueDBJob $ JobLmsEnqueue qid diff --git a/src/Jobs/Handler/QueueNotification.hs b/src/Jobs/Handler/QueueNotification.hs index cd64cb89f..ea9a0adb2 100644 --- a/src/Jobs/Handler/QueueNotification.hs +++ b/src/Jobs/Handler/QueueNotification.hs @@ -300,8 +300,8 @@ determineNotificationCandidates = awaitForever $ \notif -> do E.&&. application E.^. CourseApplicationCourse E.==. E.val nCourse return (hasOverride, user) - NotificationQualificationExpiry{} -> return mempty -- Not used with JobQueueNotification; recipients already known - NotificationQualificationRenewal{} -> return mempty -- Not used with JobQueueNotification; recipients already known + NotificationQualificationExpiry{} -> return mempty -- Not to be used with JobQueueNotification; recipients already known + NotificationQualificationRenewal{} -> return mempty -- Not to be used with JobQueueNotification; recipients already known