mirror of
https://github.com/simple-login/app.git
synced 2025-09-05 22:24:43 +08:00
22 lines
633 B
Python
22 lines
633 B
Python
import arrow
|
|
from sqlalchemy import and_
|
|
|
|
from app.alias_delete import perform_alias_deletion
|
|
from app.db import Session
|
|
from app.log import LOG
|
|
from app.models import Alias
|
|
|
|
|
|
def cleanup_alias(oldest_allowed: arrow.Arrow):
|
|
LOG.i(f"Deleting alias with delete_on older than {oldest_allowed}")
|
|
for alias in (
|
|
Alias.filter(
|
|
and_(Alias.delete_on.isnot(None), Alias.delete_on <= oldest_allowed)
|
|
)
|
|
.enable_eagerloads(False)
|
|
.yield_per(500)
|
|
.all()
|
|
):
|
|
alias: Alias = alias
|
|
perform_alias_deletion(alias, alias.user, alias.delete_reason)
|
|
Session.commit()
|