Create a new query for template monthly stats.

This commit is contained in:
Rebecca Law
2019-01-10 16:24:51 +00:00
parent 1719f31909
commit 507138cc94
4 changed files with 123 additions and 23 deletions

View File

@@ -24,7 +24,8 @@ from app.dao.fact_notification_status_dao import (
fetch_notification_status_for_service_by_month,
fetch_notification_status_for_service_for_day,
fetch_notification_status_for_service_for_today_and_7_previous_days,
fetch_stats_for_all_services_by_date_range)
fetch_stats_for_all_services_by_date_range, fetch_monthly_template_usage_for_service
)
from app.dao.inbound_numbers_dao import dao_allocate_number_for_service
from app.dao.organisation_dao import dao_get_organisation_by_service_id
from app.dao.service_data_retention_dao import (
@@ -579,10 +580,16 @@ def resume_service(service_id):
@service_blueprint.route('/<uuid:service_id>/notifications/templates_usage/monthly', methods=['GET'])
def get_monthly_template_usage(service_id):
try:
data = dao_fetch_monthly_historical_usage_by_template_for_service(
service_id,
int(request.args.get('year', 'NaN'))
start_date, end_date = get_financial_year(int(request.args.get('year', 'NaN')))
data = fetch_monthly_template_usage_for_service(
start_date=start_date,
end_date=end_date,
service_id=service_id
)
# data = dao_fetch_monthly_historical_usage_by_template_for_service(
# service_id,
# int(request.args.get('year', 'NaN'))
# )
stats = list()
for i in data: