mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-23 15:56:45 -04:00
fix rates query
This commit is contained in:
@@ -392,7 +392,7 @@ def fetch_billing_data_for_day(process_day, service_id=None, check_permissions=F
|
|||||||
def _query_for_billing_data(notification_type, start_date, end_date, service):
|
def _query_for_billing_data(notification_type, start_date, end_date, service):
|
||||||
def _email_query():
|
def _email_query():
|
||||||
return (
|
return (
|
||||||
db.session.query(
|
select(
|
||||||
NotificationAllTimeView.template_id,
|
NotificationAllTimeView.template_id,
|
||||||
literal(service.id).label("service_id"),
|
literal(service.id).label("service_id"),
|
||||||
literal(notification_type).label("notification_type"),
|
literal(notification_type).label("notification_type"),
|
||||||
@@ -402,6 +402,7 @@ def _query_for_billing_data(notification_type, start_date, end_date, service):
|
|||||||
literal(0).label("billable_units"),
|
literal(0).label("billable_units"),
|
||||||
func.count().label("notifications_sent"),
|
func.count().label("notifications_sent"),
|
||||||
)
|
)
|
||||||
|
.select_from(NotificationAllTimeView)
|
||||||
.filter(
|
.filter(
|
||||||
NotificationAllTimeView.status.in_(
|
NotificationAllTimeView.status.in_(
|
||||||
NotificationStatus.sent_email_types()
|
NotificationStatus.sent_email_types()
|
||||||
@@ -424,7 +425,7 @@ def _query_for_billing_data(notification_type, start_date, end_date, service):
|
|||||||
).cast(Integer)
|
).cast(Integer)
|
||||||
international = func.coalesce(NotificationAllTimeView.international, False)
|
international = func.coalesce(NotificationAllTimeView.international, False)
|
||||||
return (
|
return (
|
||||||
db.session.query(
|
select(
|
||||||
NotificationAllTimeView.template_id,
|
NotificationAllTimeView.template_id,
|
||||||
literal(service.id).label("service_id"),
|
literal(service.id).label("service_id"),
|
||||||
literal(notification_type).label("notification_type"),
|
literal(notification_type).label("notification_type"),
|
||||||
@@ -436,6 +437,7 @@ def _query_for_billing_data(notification_type, start_date, end_date, service):
|
|||||||
),
|
),
|
||||||
func.count().label("notifications_sent"),
|
func.count().label("notifications_sent"),
|
||||||
)
|
)
|
||||||
|
.select_from(NotificationAllTimeView)
|
||||||
.filter(
|
.filter(
|
||||||
NotificationAllTimeView.status.in_(
|
NotificationAllTimeView.status.in_(
|
||||||
NotificationStatus.billable_sms_types()
|
NotificationStatus.billable_sms_types()
|
||||||
@@ -460,12 +462,12 @@ def _query_for_billing_data(notification_type, start_date, end_date, service):
|
|||||||
}
|
}
|
||||||
|
|
||||||
query = query_funcs[notification_type]()
|
query = query_funcs[notification_type]()
|
||||||
return query.all()
|
return db.session.execute(query).all()
|
||||||
|
|
||||||
|
|
||||||
def get_rates_for_billing():
|
def get_rates_for_billing():
|
||||||
rates = Rate.query.order_by(desc(Rate.valid_from)).all()
|
stmt = select(Rate).order_by(desc(Rate.valid_from))
|
||||||
return rates
|
return db.session.execute(stmt).all()
|
||||||
|
|
||||||
|
|
||||||
def get_service_ids_that_need_billing_populated(start_date, end_date):
|
def get_service_ids_that_need_billing_populated(start_date, end_date):
|
||||||
|
|||||||
Reference in New Issue
Block a user