chore(sap): filter failed LDAP synchs for 3 months

This commit is contained in:
Steffen Jost 2023-02-24 18:20:08 +01:00
parent 3406db1dfd
commit 0b545e4d0a

View File

@ -70,8 +70,12 @@ sapRes2csv l = [ res | (Ex.Value (Just persNo), Ex.Value firstHeld, Ex.Value val
}
]
-- | Deliver all employess with a successful LDAP synch within the last 3 months
getQualificationSAPDirectR :: Handler TypedContent
getQualificationSAPDirectR = do
now <- liftIO getCurrentTime
fdate <- formatTime' "%Y%m%d_%H-%M" now
let ldap_cutoff = addDiffDaysRollOver (fromMonths $ -3) now
qualUsers <- runDB $ Ex.select $ do
(qual :& qualUser :& user) <-
Ex.from $ Ex.table @Qualification
@ -81,15 +85,15 @@ getQualificationSAPDirectR = do
`Ex.on` (\(_ :& qualUser :& user) -> qualUser Ex.^. QualificationUserUser Ex.==. user Ex.^. UserId)
Ex.where_ $ E.isJust (qual Ex.^. QualificationSapId)
Ex.&&. E.isJust (user Ex.^. UserCompanyPersonalNumber)
Ex.&&. E.isJust (user Ex.^. UserLastLdapSynchronisation)
Ex.&&. (E.justVal ldap_cutoff Ex.<=. user Ex.^. UserLastLdapSynchronisation)
return
( user Ex.^. UserCompanyPersonalNumber
, qualUser Ex.^. QualificationUserFirstHeld
, qualUser Ex.^. QualificationUserValidUntil
-- , qualUser Ex.^. QualificationUserBlockedDue
, qual Ex.^. QualificationSapId
)
now <- liftIO getCurrentTime
fdate <- formatTime' "%Y%m%d_%H-%M" now
)
let csvRendered = toCsvRendered sapUserTableCsvHeader $ sapRes2csv qualUsers
fmtOpts = def { csvIncludeHeader = True
, csvDelimiter = ','