feat(allocations): allow additional notifications
This commit is contained in:
parent
975ebfaa5a
commit
cc205596ae
@ -338,12 +338,13 @@ determineCrontab = execWriterT $ do
|
|||||||
_other
|
_other
|
||||||
-> return ()
|
-> return ()
|
||||||
doneSince <- lift $ allocationDone nAllocation
|
doneSince <- lift $ allocationDone nAllocation
|
||||||
|
|
||||||
whenIsJust doneSince $ \doneSince' ->
|
whenIsJust doneSince $ \doneSince' ->
|
||||||
tell $ HashMap.singleton
|
tell $ HashMap.singleton
|
||||||
(JobCtlQueue $ JobQueueNotification NotificationAllocationResults{..})
|
(JobCtlQueue $ JobQueueNotification NotificationAllocationResults{..})
|
||||||
Cron
|
Cron
|
||||||
{ cronInitial = CronTimestamp . utcToLocalTimeTZ appTZ $ addUTCTime appNotificationCollateDelay doneSince'
|
{ cronInitial = CronTimestamp . utcToLocalTimeTZ appTZ $ addUTCTime appNotificationCollateDelay doneSince'
|
||||||
, cronRepeat = CronRepeatNever
|
, cronRepeat = CronRepeatOnChange
|
||||||
, cronRateLimit = appNotificationRateLimit
|
, cronRateLimit = appNotificationRateLimit
|
||||||
, cronNotAfter = Left appNotificationExpiration
|
, cronNotAfter = Left appNotificationExpiration
|
||||||
}
|
}
|
||||||
|
|||||||
@ -198,7 +198,8 @@ determineNotificationCandidates NotificationExamOfficeExamResultsChanged{..} =
|
|||||||
E.where_ $ examResult E.^. ExamResultId `E.in_` E.valList (Set.toList nExamResults)
|
E.where_ $ examResult E.^. ExamResultId `E.in_` E.valList (Set.toList nExamResults)
|
||||||
E.where_ $ examOfficeExamResultAuth (user E.^. UserId) examResult
|
E.where_ $ examOfficeExamResultAuth (user E.^. UserId) examResult
|
||||||
return user
|
return user
|
||||||
determineNotificationCandidates NotificationAllocationResults{..} =
|
determineNotificationCandidates notif@NotificationAllocationResults{..} = do
|
||||||
|
lastExec <- fmap (fmap $ cronLastExecTime . entityVal) . getBy . UniqueCronLastExec . toJSON $ JobQueueNotification notif
|
||||||
E.select . E.from $ \user -> do
|
E.select . E.from $ \user -> do
|
||||||
let isStudent = E.exists . E.from $ \application ->
|
let isStudent = E.exists . E.from $ \application ->
|
||||||
E.where_ $ application E.^. CourseApplicationAllocation E.==. E.just (E.val nAllocation)
|
E.where_ $ application E.^. CourseApplicationAllocation E.==. E.just (E.val nAllocation)
|
||||||
@ -207,7 +208,19 @@ determineNotificationCandidates NotificationAllocationResults{..} =
|
|||||||
E.on $ lecturer E.^. LecturerCourse E.==. allocationCourse E.^. AllocationCourseCourse
|
E.on $ lecturer E.^. LecturerCourse E.==. allocationCourse E.^. AllocationCourseCourse
|
||||||
E.&&. allocationCourse E.^. AllocationCourseAllocation E.==. E.val nAllocation
|
E.&&. allocationCourse E.^. AllocationCourseAllocation E.==. E.val nAllocation
|
||||||
E.&&. lecturer E.^. LecturerUser E.==. user E.^. UserId
|
E.&&. lecturer E.^. LecturerUser E.==. user E.^. UserId
|
||||||
E.where_ $ isStudent E.||. isLecturer
|
|
||||||
|
wasAllocated t = E.exists . E.from $ \participant ->
|
||||||
|
E.where_ $ participant E.^. CourseParticipantUser E.==. user E.^. UserId
|
||||||
|
E.&&. participant E.^. CourseParticipantAllocated E.==. E.just (E.val nAllocation)
|
||||||
|
E.&&. participant E.^. CourseParticipantRegistration E.>. E.val t
|
||||||
|
hasAllocations t = E.exists . E.from $ \(lecturer `E.InnerJoin` participant) -> do
|
||||||
|
E.on $ lecturer E.^. LecturerUser E.==. user E.^. UserId
|
||||||
|
E.&&. lecturer E.^. LecturerCourse E.==. participant E.^. CourseParticipantCourse
|
||||||
|
E.where_ $ participant E.^. CourseParticipantAllocated E.==. E.just (E.val nAllocation)
|
||||||
|
E.&&. participant E.^. CourseParticipantRegistration E.>. E.val t
|
||||||
|
case lastExec of
|
||||||
|
Nothing -> E.where_ $ isStudent E.||. isLecturer
|
||||||
|
Just t -> E.where_ $ wasAllocated t E.||. hasAllocations t
|
||||||
|
|
||||||
return user
|
return user
|
||||||
determineNotificationCandidates NotificationCourseRegistered{..} =
|
determineNotificationCandidates NotificationCourseRegistered{..} =
|
||||||
|
|||||||
Reference in New Issue
Block a user