mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 18:01:08 -05:00
Renamed some files and fixed a bug on deleting the failed notifications
This commit is contained in:
@@ -21,9 +21,9 @@ def get_invited_users_for_service(service_id):
|
||||
return InvitedUser.query.filter_by(service_id=service_id).all()
|
||||
|
||||
|
||||
def delete_invitations_older_created_more_than_a_day_ago():
|
||||
def delete_invitations_created_more_than_two_days_ago():
|
||||
deleted = db.session.query(InvitedUser).filter(
|
||||
InvitedUser.created_at <= datetime.utcnow() - timedelta(days=1)
|
||||
InvitedUser.created_at <= datetime.utcnow() - timedelta(days=2)
|
||||
).delete()
|
||||
db.session.commit()
|
||||
return deleted
|
||||
|
||||
@@ -89,7 +89,7 @@ def get_notifications_for_service(service_id, page=1):
|
||||
|
||||
def delete_successful_notifications_created_more_than_a_day_ago():
|
||||
deleted = db.session.query(Notification).filter(
|
||||
Notification.created_at < datetime.utcnow() - timedelta(hours=24),
|
||||
Notification.created_at < datetime.utcnow() - timedelta(days=1),
|
||||
Notification.status == 'sent'
|
||||
).delete()
|
||||
db.session.commit()
|
||||
@@ -98,7 +98,7 @@ def delete_successful_notifications_created_more_than_a_day_ago():
|
||||
|
||||
def delete_failed_notifications_created_more_than_a_week_ago():
|
||||
deleted = db.session.query(Notification).filter(
|
||||
Notification.created_at < datetime.utcnow() - timedelta(hours=24 * 7),
|
||||
Notification.created_at < datetime.utcnow() - timedelta(days=7),
|
||||
Notification.status == 'failed'
|
||||
).delete()
|
||||
db.session.commit()
|
||||
|
||||
Reference in New Issue
Block a user