Now that we are in British Summer Time the delete notification scheduled tasks were running at 23:40, but the code expects that the task runs the following day.

Which resulted in the notifications being around for 8 days.
This PR fixes that.
This commit is contained in:
Rebecca Law
2018-04-04 12:20:36 +01:00
parent c392053847
commit e47b9364d9
2 changed files with 22 additions and 37 deletions

View File

@@ -46,6 +46,7 @@ from app.models import (
)
from app.dao.dao_utils import transactional
from app.utils import convert_utc_to_bst
@statsd(namespace="dao")
@@ -317,7 +318,7 @@ def _filter_query(query, filter_dict=None):
@statsd(namespace="dao")
@transactional
def delete_notifications_created_more_than_a_week_ago_by_type(notification_type):
seven_days_ago = date.today() - timedelta(days=7)
seven_days_ago = convert_utc_to_bst(datetime.utcnow()).date() - timedelta(days=7)
deleted = db.session.query(Notification).filter(
func.date(Notification.created_at) < seven_days_ago,
Notification.notification_type == notification_type,