From 2dd73d195be8e12d6b4cace4816e410dc6ce4a9d Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Wed, 8 Oct 2025 12:10:01 -0700 Subject: [PATCH 1/3] reverse template usage --- app/main/views/dashboard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index c8ed951a0..8683b5a62 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -194,7 +194,7 @@ def template_usage(service_id): get_monthly_template_stats(month, stats) for month in get_months_for_financial_year(year, time_format="%B") ] - + months.reverse() return render_template( "views/dashboard/all-template-statistics.html", months=months, From e8d87733513537d2e95033108640f13d9e180f3d Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Thu, 9 Oct 2025 07:31:15 -0700 Subject: [PATCH 2/3] fix so we only show up to current month --- app/main/views/dashboard.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index 8683b5a62..d84727569 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -195,6 +195,22 @@ def template_usage(service_id): for month in get_months_for_financial_year(year, time_format="%B") ] months.reverse() + + # Get the year from stats + # If the year is this year, remove months in the future + if len(stats) > 0: + stat_year = stats[0]["year"] + current_year = datetime.now().year + current_month_num = datetime.now().month + new_months = [] + if stat_year == current_year: + for m in months: + + month_num_full = datetime.strptime(m["name"], "%B").month + if month_num_full <= current_month_num: + new_months.append(m) + months = new_months + return render_template( "views/dashboard/all-template-statistics.html", months=months, From 20247419df60bc47da86c72bb387fc27decdaf08 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Thu, 9 Oct 2025 13:25:35 -0700 Subject: [PATCH 3/3] fix tests --- tests/app/main/views/test_dashboard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index dbabba8a8..a474c5eaf 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -410,7 +410,7 @@ def test_should_not_show_recent_templates_on_dashboard_if_only_one_template_used assert expected_count == 50, f"Expected count to be 50, but got {expected_count}" -@freeze_time("2017-01-01 12:00") +@freeze_time("2017-12-01 12:00") @pytest.mark.parametrize( "extra_args", [