Skip to content

Commit

Permalink
Add docstring to function (#2051)
Browse files Browse the repository at this point in the history
* added docstring to function

* rename year -> financial_year
  • Loading branch information
smcmurtry authored Jan 20, 2025
1 parent bba9c29 commit 2fa1733
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/main/views/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def aggregate_by_type(data, daily_data):
bounce_rate_data = get_bounce_rate_data_from_redis(service_id)

# get annual data from fact table (all data this year except today)
annual_data = service_api_client.get_monthly_notification_stats(service_id, year=get_current_financial_year())
annual_data = service_api_client.get_monthly_notification_stats(service_id, get_current_financial_year())
annual_data = aggregate_by_type(annual_data, dashboard_totals_daily[0])

return {
Expand Down
21 changes: 19 additions & 2 deletions app/notify_client/service_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,28 @@ def get_service_history(self, service_id):

# TODO: cache this once the backend is updated to exlude data from the current day
# @flask_cache.memoize(timeout=_seconds_until_midnight())
def get_monthly_notification_stats(self, service_id, year):
def get_monthly_notification_stats(self, service_id: str, financial_year: int):
"""
Retrieve monthly notification statistics for a specific service and year.
Args:
service_id (str): UUID of the service to get statistics for
financial_year (int): The financial year to fetch statistics for (YYYY format)
Returns:
dict: Monthly notification statistics like this:
{
'data': {
'2024-04': {'sms': {}, 'email': {}, 'letter': {}},
'2024-05': {'sms': {}, 'email': {'technical-failure': 1, 'sending': 26}, 'letter': {}},
...
},
}
"""
return self.get(
url="/service/{}/notifications/monthly?year={}".format(
service_id,
year,
financial_year,
)
)

Expand Down

0 comments on commit 2fa1733

Please sign in to comment.