mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
updating pending count
This commit is contained in:
@@ -2,7 +2,7 @@ import uuid
|
||||
from datetime import timedelta
|
||||
|
||||
from flask import current_app
|
||||
from sqlalchemy import Float, cast, delete, select
|
||||
from sqlalchemy import Float, cast, delete, select, Integer
|
||||
from sqlalchemy.orm import joinedload
|
||||
from sqlalchemy.sql.expression import and_, asc, case, func
|
||||
|
||||
@@ -458,16 +458,13 @@ def dao_fetch_stats_for_service_from_days(service_id, start_date, end_date):
|
||||
sub_stmt = (
|
||||
select(
|
||||
Job.id,
|
||||
Job.notification_count,
|
||||
cast(Job.notification_count, Integer).label("notification_count"), # <-- i added cast here
|
||||
NotificationAllTimeView.notification_type,
|
||||
NotificationAllTimeView.status,
|
||||
func.date_trunc("day", NotificationAllTimeView.created_at).label("day"),
|
||||
func.count(NotificationAllTimeView.id).label("count"),
|
||||
)
|
||||
.join_from(
|
||||
NotificationAllTimeView,
|
||||
Job,
|
||||
cast(func.count(NotificationAllTimeView.id), Integer).label("count"), # <-- i added cast here
|
||||
)
|
||||
.join_from(NotificationAllTimeView, Job, NotificationAllTimeView.job_id == Job.id) # <-- i changed this to NotificationAllTimeView from notifications
|
||||
.where(
|
||||
NotificationAllTimeView.service_id == service_id,
|
||||
NotificationAllTimeView.key_type != KeyType.TEST,
|
||||
@@ -486,21 +483,22 @@ def dao_fetch_stats_for_service_from_days(service_id, start_date, end_date):
|
||||
|
||||
stmt = (
|
||||
select(
|
||||
func.sum(sub_stmt.notification_count).label("total_notifications"),
|
||||
sub_stmt.notification_type,
|
||||
sub_stmt.status,
|
||||
sub_stmt.day,
|
||||
func.sum(sub_stmt.count).label("count"),
|
||||
cast(func.sum(sub_stmt.c.notification_count), Integer).label("total_notifications"), # <-- i added cast here
|
||||
sub_stmt.c.notification_type,
|
||||
sub_stmt.c.status,
|
||||
sub_stmt.c.day,
|
||||
cast(func.sum(sub_stmt.c.count), Integer).label("count"), # <-- i added cast here
|
||||
)
|
||||
.group_by(
|
||||
sub_stmt.notification_type,
|
||||
sub_stmt.status,
|
||||
sub_stmt.day,
|
||||
.group_by( # <-- i added this group here
|
||||
sub_stmt.c.notification_type,
|
||||
sub_stmt.c.status,
|
||||
sub_stmt.c.day
|
||||
)
|
||||
)
|
||||
return db.session.execute(stmt).all()
|
||||
|
||||
|
||||
|
||||
def dao_fetch_stats_for_service_from_days_for_user(
|
||||
service_id, start_date, end_date, user_id
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user