mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
Merge branch 'master' into stats-db-updates
Conflicts: tests/app/conftest.py
This commit is contained in:
@@ -157,3 +157,21 @@ def _stats_for_service_query(service_id):
|
||||
Notification.notification_type,
|
||||
Notification.status,
|
||||
)
|
||||
|
||||
|
||||
def dao_fetch_weekly_historical_stats_for_service(service_id):
|
||||
monday_of_notification_week = func.date_trunc('week', NotificationHistory.created_at).label('week_start')
|
||||
return db.session.query(
|
||||
NotificationHistory.notification_type,
|
||||
NotificationHistory.status,
|
||||
monday_of_notification_week,
|
||||
func.count(NotificationHistory.id).label('count')
|
||||
).filter(
|
||||
NotificationHistory.service_id == service_id
|
||||
).group_by(
|
||||
NotificationHistory.notification_type,
|
||||
NotificationHistory.status,
|
||||
monday_of_notification_week
|
||||
).order_by(
|
||||
asc(monday_of_notification_week), NotificationHistory.status
|
||||
).all()
|
||||
|
||||
Reference in New Issue
Block a user