diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index 553ad8b3d..b666b3f8b 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -12,6 +12,7 @@ from flask import ( ) from flask_login import login_required from notifications_utils.recipients import format_phone_number_human_readable +from werkzeug.routing import RequestRedirect from app.main import main from app import ( @@ -75,35 +76,7 @@ def service_dashboard_updates(service_id): @user_has_permissions('view_activity', admin_override=True) def template_history(service_id): - year, current_financial_year = requested_and_current_financial_year(request) - stats = template_statistics_client.get_monthly_template_statistics_for_service(service_id, year) - - months = [ - { - 'name': yyyy_mm_to_datetime(month).strftime('%B'), - 'templates_used': aggregate_usage( - format_template_stats_to_list(stats.get(month)), sort_key='requested_count' - ), - } - for month in get_months_for_financial_year(year, time_format='%Y-%m') - ] - - return render_template( - 'views/dashboard/all-template-statistics.html', - months=months, - most_used_template_count=max( - max(( - template['requested_count'] - for template in month['templates_used'] - ), default=0) - for month in months - ), - years=get_tuples_of_financial_years( - partial(url_for, '.template_history', service_id=service_id), - end=current_financial_year, - ), - selected_year=year, - ) + raise RequestRedirect("/services/{}/template-usage".format(service_id)) @main.route("/services//template-usage") diff --git a/app/templates/views/dashboard/dashboard.html b/app/templates/views/dashboard/dashboard.html index c7d419443..01bf9324c 100644 --- a/app/templates/views/dashboard/dashboard.html +++ b/app/templates/views/dashboard/dashboard.html @@ -40,7 +40,7 @@ {% if partials['has_template_statistics'] %} {{ ajax_block(partials, updates_url, 'template-statistics') }} {{ show_more( - url_for('.template_history', service_id=current_service.id), + url_for('.template_usage', service_id=current_service.id), 'See templates used by month' ) }} {% endif %}