Minor tweaks in response to PR comments

In response to [^1] and [^2].

[^1]: https://github.com/alphagov/notifications-admin/pull/4229#discussion_r869181152
[^2]: https://github.com/alphagov/notifications-admin/pull/4229#discussion_r869186063
This commit is contained in:
Ben Thorner
2022-05-10 16:48:03 +01:00
parent 3449ccd923
commit bb0fb73bc8
3 changed files with 11 additions and 5 deletions

View File

@@ -423,6 +423,10 @@ def get_monthly_usage_breakdown_for_letters(monthly_letters):
postage_order[get_monthly_usage_postage_description(row)], row['rate']
)
# First sort letter rows by postage and then by rate, clumping "europe" and
# "rest-of-world" postage together as "international". Group the sorted rows
# together using the same fields - "group_key" is used for both operations.
# Note that "groupby" preserves the sort order in the groups it returns.
rate_groups = groupby(sorted(monthly_letters, key=group_key), key=group_key)
for _key, rate_group in rate_groups: