mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
add new daily sms provider volume report
code generally lifted almost exactly from the daily_volumes_report, but per provider and only for SMS.
This commit is contained in:
@@ -779,6 +779,31 @@ def fetch_daily_volumes_for_platform(start_date, end_date):
|
||||
return aggregated_totals
|
||||
|
||||
|
||||
def fetch_daily_sms_provider_volumes_for_platform(start_date, end_date):
|
||||
# query to return the total notifications sent per day for each channel. NB start and end dates are inclusive
|
||||
|
||||
daily_volume_stats = db.session.query(
|
||||
FactBilling.bst_date,
|
||||
FactBilling.provider,
|
||||
func.sum(FactBilling.notifications_sent).label('sms_totals'),
|
||||
func.sum(FactBilling.billable_units).label('sms_fragment_totals'),
|
||||
func.sum(FactBilling.billable_units * FactBilling.rate_multiplier).label('sms_chargeable_units'),
|
||||
func.sum(FactBilling.billable_units * FactBilling.rate_multiplier * FactBilling.rate).label('sms_cost'),
|
||||
).filter(
|
||||
FactBilling.notification_type == SMS_TYPE,
|
||||
FactBilling.bst_date >= start_date,
|
||||
FactBilling.bst_date <= end_date,
|
||||
).group_by(
|
||||
FactBilling.bst_date,
|
||||
FactBilling.provider,
|
||||
).order_by(
|
||||
FactBilling.bst_date,
|
||||
FactBilling.provider,
|
||||
).all()
|
||||
|
||||
return daily_volume_stats
|
||||
|
||||
|
||||
def fetch_volumes_by_service(start_date, end_date):
|
||||
# query to return the volume totals by service aggregated for the date range given
|
||||
# start and end dates are inclusive.
|
||||
|
||||
Reference in New Issue
Block a user