fradrive/src/Jobs/Handler/PruneInvitations.hs

13 lines
386 B
Haskell

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