chore(lms): correct job handler ulist to deal with repeated uploads
This commit is contained in:
parent
c7f734cfca
commit
5f2f353007
@ -66,24 +66,21 @@ QualificationUser
|
|||||||
-- - delete-flag: isJust LmsUserStatus
|
-- - delete-flag: isJust LmsUserStatus
|
||||||
-- Note: REST means that LmsUserResetPin and LmsUserDelete remain unchanged by this GET request!
|
-- Note: REST means that LmsUserResetPin and LmsUserDelete remain unchanged by this GET request!
|
||||||
--
|
--
|
||||||
-- 3. REST POST Userlist.csv:
|
-- 3. REST POST Userlist.csv: just save as is to LmsUserlist
|
||||||
-- -- save as is to LmsUserlist
|
|
||||||
-- -- change LmsUserEnded from Nothing to Just now, if not included in received list
|
|
||||||
--
|
--
|
||||||
-- 4. REST POST Ergebnisse.csv: just save as is to LmsResult
|
-- 4. REST POST Ergebnisse.csv: just save as is to LmsResult
|
||||||
--
|
--
|
||||||
-- 5. Daily Job LmsUserlist: -- Note: containment needs at-once processing
|
-- 5. Daily Job LmsUserlist: -- Note: containment needs at-once processing
|
||||||
-- - For all LmsUser:
|
-- - For all LmsUser:
|
||||||
-- + if contained, set LmsUserReceived to Just now()
|
-- + if contained:
|
||||||
-- + otherwise, set LmsUserEnded to Just now()
|
-- set LmsUserReceived to Just now()
|
||||||
-- - if LmsUserlistFailed:
|
-- if LmsUserlistFailed: set LmsUserStatus to Just Day
|
||||||
-- + set LmsUserStatus to Just Day
|
-- + not contianed, by LmsUserReceived is set: set LmsUserEnded to Just now()
|
||||||
-- + set LmsUserDelete to True
|
|
||||||
-- - move row to LmsAudit
|
-- - move row to LmsAudit
|
||||||
--
|
--
|
||||||
-- 6. Daily Job LmsResult:
|
-- 6. Daily Job LmsResult:
|
||||||
-- - set LmsUserReceived to Just now()
|
-- - set LmsUserReceived to Just now()
|
||||||
-- - set LmsUserStatus to Just Day
|
-- - set LmsUserStatus to Just Day -- always
|
||||||
-- - move row to LmsAudit
|
-- - move row to LmsAudit
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -57,6 +57,7 @@ dispatchJobLmsResults qid = JobHandlerAtomic act
|
|||||||
-- three separate DB operations per result is not so nice. All within one transaction though.
|
-- three separate DB operations per result is not so nice. All within one transaction though.
|
||||||
let lreceived = lmsResultTimestamp lresult
|
let lreceived = lmsResultTimestamp lresult
|
||||||
lstatus = lmsResultSuccess lresult & LmsSuccess
|
lstatus = lmsResultSuccess lresult & LmsSuccess
|
||||||
|
-- always log success, since this is only transmitted once
|
||||||
update luid [ LmsUserStatus =. Just lstatus
|
update luid [ LmsUserStatus =. Just lstatus
|
||||||
, LmsUserReceived =. Just lreceived
|
, LmsUserReceived =. Just lreceived
|
||||||
]
|
]
|
||||||
@ -80,16 +81,21 @@ dispatchJobLmsUserlist qid = JobHandlerAtomic act
|
|||||||
E.&&. E.isNothing (luser E.^. LmsUserEnded) -- do not process closed learners
|
E.&&. E.isNothing (luser E.^. LmsUserEnded) -- do not process closed learners
|
||||||
return (luser, lulist)
|
return (luser, lulist)
|
||||||
forM_ results $ \case
|
forM_ results $ \case
|
||||||
(Entity luid _luser, Nothing) ->
|
(Entity luid luser, Nothing)
|
||||||
update luid [LmsUserEnded =. Just now]
|
| isJust $ lmsUserReceived luser
|
||||||
|
, isNothing $ lmsUserEnded luser ->
|
||||||
|
update luid [LmsUserEnded =. Just now]
|
||||||
|
| otherwise -> return () -- likely not yet started
|
||||||
|
|
||||||
(Entity luid luser, Just (Entity lulid lulist)) -> do
|
(Entity luid luser, Just (Entity lulid lulist)) -> do
|
||||||
let lreceived = lmsUserlistTimestamp lulist
|
let usrNoStat = isNothing $ lmsUserStatus luser
|
||||||
lblocked = lmsUserlistFailed lulist
|
lBlocked = lmsUserlistFailed lulist
|
||||||
lstatus = LmsBlocked $ utctDay lreceived
|
updStatus = lBlocked && usrNoStat -- only update empty status to blocked
|
||||||
update luid $ [ LmsUserStatus =. Just lstatus | lblocked ]
|
lReceived = lmsUserlistTimestamp lulist
|
||||||
<> [ LmsUserReceived =. Just lreceived ]
|
lStatus = LmsBlocked $ utctDay lReceived
|
||||||
when lblocked . insert_ $ LmsAudit qid (lmsUserIdent luser) lstatus lreceived now
|
update luid $ [ LmsUserStatus =. Just lStatus | updStatus ]
|
||||||
|
<> [ LmsUserReceived =. Just lReceived ]
|
||||||
|
when lBlocked . insert_ $ LmsAudit qid (lmsUserIdent luser) lStatus lReceived now -- always log blocked
|
||||||
delete lulid
|
delete lulid
|
||||||
|
|
||||||
$logInfoS "LmsUserlist" [st|Processed LMS Userlist with ${tshow (length results)} entries|]
|
$logInfoS "LmsUserlist" [st|Processed LMS Userlist with ${tshow (length results)} entries|]
|
||||||
|
|||||||
Reference in New Issue
Block a user