mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
use ft_notification_status and notifications for job statistics
we previously always read from NotificationHistory to get the notification status stats for a job. Now, if the job is more than three days old read from ft_notification_status table, otherwise read from the notifications table (to keep live updates).
This commit is contained in:
@@ -186,3 +186,14 @@ def fetch_notification_status_totals_for_all_services(start_date, end_date):
|
||||
else:
|
||||
query = stats
|
||||
return query.all()
|
||||
|
||||
|
||||
def fetch_notification_statuses_for_job(job_id):
|
||||
return db.session.query(
|
||||
FactNotificationStatus.notification_status.label('status'),
|
||||
func.sum(FactNotificationStatus.notification_count).label('count'),
|
||||
).filter(
|
||||
FactNotificationStatus.job_id == job_id,
|
||||
).group_by(
|
||||
FactNotificationStatus.notification_status
|
||||
).all()
|
||||
|
||||
Reference in New Issue
Block a user