mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-17 13:09:42 -04:00
Merge pull request #2989 from GSA/template_usage
reverse template usage
This commit is contained in:
@@ -194,6 +194,22 @@ 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()
|
||||
|
||||
# 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",
|
||||
|
||||
@@ -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",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user