mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-23 11:29:50 -05:00
Merge pull request #1928 from alphagov/platform-stats-fix
Fix aggregate stats DAO function to use start_date
This commit is contained in:
@@ -621,7 +621,7 @@ def fetch_aggregate_stats_by_date_range_for_all_services(start_date, end_date):
|
||||
end_date = get_london_midnight_in_utc(end_date + timedelta(days=1))
|
||||
table = NotificationHistory
|
||||
|
||||
if end_date >= datetime.utcnow() - timedelta(days=7):
|
||||
if start_date >= datetime.utcnow() - timedelta(days=7):
|
||||
table = Notification
|
||||
|
||||
query = db.session.query(
|
||||
|
||||
@@ -1982,17 +1982,3 @@ def test_fetch_aggregate_stats_by_date_range_for_all_services_uses_bst_date(samp
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0].status == 'sent'
|
||||
|
||||
|
||||
@freeze_time('2018-01-08T12:00:00')
|
||||
def test_fetch_aggregate_stats_by_date_range_for_all_services_gets_test_notifications_when_start_date_over_7_days_ago(
|
||||
sample_template
|
||||
):
|
||||
ten_days_ago = datetime.utcnow().date() - timedelta(days=10)
|
||||
today = datetime.utcnow().date()
|
||||
|
||||
create_notification(sample_template, key_type=KEY_TYPE_TEST, created_at=datetime.utcnow())
|
||||
|
||||
result = fetch_aggregate_stats_by_date_range_for_all_services(ten_days_ago, today)
|
||||
|
||||
assert len(result) == 1
|
||||
|
||||
Reference in New Issue
Block a user