Make GC emails also delete orphaned verifications
This commit is contained in:
parent
04d0efb545
commit
3666f29756
|
@ -137,6 +137,13 @@ deleteExpiredEmails time = runQuery $ delete $ do
|
||||||
verification <- from $ table @DBEmailVerification
|
verification <- from $ table @DBEmailVerification
|
||||||
where_ $ verification ^. DBEmailVerificationExpires <=. val time
|
where_ $ verification ^. DBEmailVerificationExpires <=. val time
|
||||||
|
|
||||||
|
deleteOrphanedVerifications :: MonadDB m => m ()
|
||||||
|
deleteOrphanedVerifications = runQuery $ delete $ do
|
||||||
|
verification <- from $ table @DBEmailVerification
|
||||||
|
where_ $ (==. val (0 :: Int)) $ subSelectCount $ do
|
||||||
|
email <- from $ table @DBEmail
|
||||||
|
where_ $ email ^. DBEmailVid ==. just (verification ^. DBEmailVerificationId)
|
||||||
|
|
||||||
deleteUsersWithoutEmail :: MonadDB m => m ()
|
deleteUsersWithoutEmail :: MonadDB m => m ()
|
||||||
deleteUsersWithoutEmail = runQuery $ delete $ do
|
deleteUsersWithoutEmail = runQuery $ delete $ do
|
||||||
user <- from $ table @DBUser
|
user <- from $ table @DBUser
|
||||||
|
|
|
@ -58,6 +58,7 @@ gcEmailsMain :: CLIM ()
|
||||||
gcEmailsMain = do
|
gcEmailsMain = do
|
||||||
time <- currentTime
|
time <- currentTime
|
||||||
deleteExpiredEmails time
|
deleteExpiredEmails time
|
||||||
|
deleteOrphanedVerifications
|
||||||
|
|
||||||
gcApplicationsMain :: CLIM ()
|
gcApplicationsMain :: CLIM ()
|
||||||
gcApplicationsMain = do
|
gcApplicationsMain = do
|
||||||
|
|
Loading…
Reference in New Issue