mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 18:31:13 -05:00
Move notification retrieval logic into perf platform client and dont filter by status
This commit is contained in:
@@ -22,15 +22,11 @@ from app.models import (
|
||||
NOTIFICATION_PENDING,
|
||||
NOTIFICATION_TECHNICAL_FAILURE,
|
||||
NOTIFICATION_TEMPORARY_FAILURE,
|
||||
NOTIFICATION_STATUS_TYPES_COMPLETED,
|
||||
KEY_TYPE_NORMAL, KEY_TYPE_TEST
|
||||
)
|
||||
|
||||
from app.dao.dao_utils import transactional
|
||||
from app.statsd_decorators import statsd
|
||||
from app.utils import (
|
||||
get_midnight_for_day_before,
|
||||
get_london_midnight_in_utc)
|
||||
|
||||
|
||||
def dao_get_notification_statistics_for_service_and_day(service_id, day):
|
||||
@@ -419,27 +415,9 @@ def get_total_sent_notifications_in_date_range(start_date, end_date, notificatio
|
||||
func.count(NotificationHistory.id).label('count')
|
||||
).filter(
|
||||
NotificationHistory.key_type != KEY_TYPE_TEST,
|
||||
NotificationHistory.status.in_(NOTIFICATION_STATUS_TYPES_COMPLETED),
|
||||
NotificationHistory.created_at >= start_date,
|
||||
NotificationHistory.created_at <= end_date,
|
||||
NotificationHistory.notification_type == notification_type
|
||||
).first()
|
||||
).scalar()
|
||||
|
||||
return 0 if result is None else result.count
|
||||
|
||||
|
||||
def get_total_sent_notifications_yesterday():
|
||||
today = datetime.utcnow()
|
||||
start_date = get_midnight_for_day_before(today)
|
||||
end_date = get_london_midnight_in_utc(today)
|
||||
|
||||
return {
|
||||
"start_date": start_date,
|
||||
"end_date": end_date,
|
||||
"email": {
|
||||
"count": get_total_sent_notifications_in_date_range(start_date, end_date, 'email')
|
||||
},
|
||||
"sms": {
|
||||
"count": get_total_sent_notifications_in_date_range(start_date, end_date, 'sms')
|
||||
}
|
||||
}
|
||||
return result or 0
|
||||
|
||||
Reference in New Issue
Block a user