mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
Remove Notification, NotificationHistory status labels:
Replace labels by adding a key kwarg in the model for status. We still need this as sqlalchemy attmempts to look for `notification_status` on the model (Notification/NotificationHistory). To achieve true ORM mapping (map status -> notification_status) we need the key kwarg. More here: http://docs.sqlalchemy.org/en/latest/core/metadata.html#sqlalchemy.schema.Column#key
This commit is contained in:
@@ -262,8 +262,7 @@ def fetch_todays_total_message_count(service_id):
|
||||
def _stats_for_service_query(service_id):
|
||||
return db.session.query(
|
||||
Notification.notification_type,
|
||||
# see dao_fetch_todays_stats_for_all_services for why we have this label
|
||||
Notification.status.label('status'),
|
||||
Notification.status,
|
||||
func.count(Notification.id).label('count')
|
||||
).filter(
|
||||
Notification.service_id == service_id,
|
||||
@@ -281,8 +280,7 @@ def dao_fetch_monthly_historical_stats_by_template_for_service(service_id, year)
|
||||
start_date, end_date = get_financial_year(year)
|
||||
sq = db.session.query(
|
||||
NotificationHistory.template_id,
|
||||
# see dao_fetch_todays_stats_for_all_services for why we have this label
|
||||
NotificationHistory.status.label('status'),
|
||||
NotificationHistory.status,
|
||||
month.label('month'),
|
||||
func.count().label('count')
|
||||
).filter(
|
||||
@@ -298,7 +296,7 @@ def dao_fetch_monthly_historical_stats_by_template_for_service(service_id, year)
|
||||
Template.id.label('template_id'),
|
||||
Template.name,
|
||||
Template.template_type,
|
||||
sq.c.status.label('status'),
|
||||
sq.c.status,
|
||||
sq.c.count.label('count'),
|
||||
sq.c.month
|
||||
).join(
|
||||
@@ -316,8 +314,7 @@ def dao_fetch_monthly_historical_stats_for_service(service_id, year):
|
||||
start_date, end_date = get_financial_year(year)
|
||||
rows = db.session.query(
|
||||
NotificationHistory.notification_type,
|
||||
# see dao_fetch_todays_stats_for_all_services for why we have this label
|
||||
NotificationHistory.status.label('status'),
|
||||
NotificationHistory.status,
|
||||
month,
|
||||
func.count(NotificationHistory.id).label('count')
|
||||
).filter(
|
||||
@@ -356,9 +353,7 @@ def dao_fetch_monthly_historical_stats_for_service(service_id, year):
|
||||
def dao_fetch_todays_stats_for_all_services(include_from_test_key=True):
|
||||
query = db.session.query(
|
||||
Notification.notification_type,
|
||||
# this label is necessary as the column has a different name under the hood (_status_enum / _status_fkey),
|
||||
# if we query the Notification object there is a hybrid property to translate, but here there isn't anything.
|
||||
Notification.status.label('status'),
|
||||
Notification.status,
|
||||
Notification.service_id,
|
||||
func.count(Notification.id).label('count')
|
||||
).filter(
|
||||
@@ -388,8 +383,7 @@ def fetch_stats_by_date_range_for_all_services(start_date, end_date, include_fro
|
||||
|
||||
query = db.session.query(
|
||||
table.notification_type,
|
||||
# see dao_fetch_todays_stats_for_all_services for why we have this label
|
||||
table.status.label('status'),
|
||||
table.status,
|
||||
table.service_id,
|
||||
func.count(table.id).label('count')
|
||||
).filter(
|
||||
|
||||
Reference in New Issue
Block a user