mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-23 07:46:06 -04:00
@@ -195,7 +195,9 @@ def fetch_notification_status_for_service_for_today_and_7_previous_days(
|
|||||||
def fetch_notification_status_totals_for_all_services(start_date, end_date):
|
def fetch_notification_status_totals_for_all_services(start_date, end_date):
|
||||||
stats = (
|
stats = (
|
||||||
db.session.query(
|
db.session.query(
|
||||||
FactNotificationStatus.notification_type.cast(db.Text).label("notification_type"),
|
FactNotificationStatus.notification_type.cast(db.Text).label(
|
||||||
|
"notification_type"
|
||||||
|
),
|
||||||
FactNotificationStatus.notification_status.cast(db.Text).label("status"),
|
FactNotificationStatus.notification_status.cast(db.Text).label("status"),
|
||||||
FactNotificationStatus.key_type.cast(db.Text).label("key_type"),
|
FactNotificationStatus.key_type.cast(db.Text).label("key_type"),
|
||||||
func.sum(FactNotificationStatus.notification_count).label("count"),
|
func.sum(FactNotificationStatus.notification_count).label("count"),
|
||||||
@@ -270,8 +272,10 @@ def fetch_stats_for_all_services_by_date_range(
|
|||||||
Service.restricted.label("restricted"),
|
Service.restricted.label("restricted"),
|
||||||
Service.active.label("active"),
|
Service.active.label("active"),
|
||||||
Service.created_at.label("created_at"),
|
Service.created_at.label("created_at"),
|
||||||
FactNotificationStatus.notification_type.label("notification_type"),
|
FactNotificationStatus.notification_type.cast(db.Text).label(
|
||||||
FactNotificationStatus.notification_status.label("status"),
|
"notification_type"
|
||||||
|
),
|
||||||
|
FactNotificationStatus.notification_status.cast(db.Text).label("status"),
|
||||||
func.sum(FactNotificationStatus.notification_count).label("count"),
|
func.sum(FactNotificationStatus.notification_count).label("count"),
|
||||||
)
|
)
|
||||||
.filter(
|
.filter(
|
||||||
@@ -321,8 +325,8 @@ def fetch_stats_for_all_services_by_date_range(
|
|||||||
Service.restricted.label("restricted"),
|
Service.restricted.label("restricted"),
|
||||||
Service.active.label("active"),
|
Service.active.label("active"),
|
||||||
Service.created_at.label("created_at"),
|
Service.created_at.label("created_at"),
|
||||||
subquery.c.notification_type.label("notification_type"),
|
subquery.c.notification_type.cast(db.Text).label("notification_type"),
|
||||||
subquery.c.status.label("status"),
|
subquery.c.status.cast(db.Text).label("status"),
|
||||||
subquery.c.count.label("count"),
|
subquery.c.count.label("count"),
|
||||||
).outerjoin(subquery, subquery.c.service_id == Service.id)
|
).outerjoin(subquery, subquery.c.service_id == Service.id)
|
||||||
|
|
||||||
|
|||||||
@@ -857,7 +857,7 @@ def test_get_total_notifications_for_date_range(sample_service):
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert len(results) == 1
|
assert len(results) == 1
|
||||||
assert results[0] == ("2021-03-01", 15, 20)
|
assert results[0] == (date.fromisoformat("2021-03-01"), 15, 20)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip(reason="Need a better way to test variable DST date")
|
@pytest.mark.skip(reason="Need a better way to test variable DST date")
|
||||||
|
|||||||
Reference in New Issue
Block a user