fradrive/src/Jobs/Handler/PruneInvitations.hs
2020-09-21 13:31:53 +02:00

16 lines
469 B
Haskell

module Jobs.Handler.PruneInvitations
( dispatchJobPruneInvitations
) where
import Import
import Database.Persist.Sql (deleteWhereCount)
dispatchJobPruneInvitations :: JobHandler UniWorX
dispatchJobPruneInvitations = JobHandlerAtomicWithFinalizer act fin
where
act = hoist lift $ do
now <- liftIO getCurrentTime
deleteWhereCount [ InvitationExpiresAt <. Just now ]
fin n = $logInfoS "PruneInvitations" [st|Deleted #{n} expired invitations|]