Skip to content

Commit

Permalink
Fixed the send to get data for notification_count_for_the_year (#2029)
Browse files Browse the repository at this point in the history
* Fixed the send to get data for notification_count_for_the_year

* fix

* fix
  • Loading branch information
jzbahrai authored Jan 6, 2025
1 parent 4a8db7a commit 99133d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions app/notify_client/notification_counts_client.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from datetime import datetime

from notifications_utils.clients.redis import (
email_daily_count_cache_key,
sms_daily_count_cache_key,
)

from app import redis_client, service_api_client, template_statistics_client
from app.models.service import Service
from app.utils import get_current_financial_year


class NotificationCounts:
Expand Down Expand Up @@ -83,8 +82,10 @@ def get_limit_stats(self, service: Service):
}
"""

current_financial_year = get_current_financial_year()
sent_today = self.get_all_notification_counts_for_today(service.id)
sent_thisyear = self.get_all_notification_counts_for_year(service.id, datetime.now().year)
# We are interested in getting data for the financial year, not the calendar year
sent_thisyear = self.get_all_notification_counts_for_year(service.id, current_financial_year)

limit_stats = {
"email": {
Expand Down
7 changes: 5 additions & 2 deletions tests/app/notify_client/test_notification_counts_client.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from datetime import datetime
from unittest.mock import Mock, patch

import pytest

from app.notify_client.notification_counts_client import NotificationCounts
from app.utils import get_current_financial_year


@pytest.fixture
Expand Down Expand Up @@ -199,4 +199,7 @@ def test_get_limit_stats_dependencies_called(self, mocker):

# Assert dependencies called
mock_today.assert_called_once_with(mock_service.id)
mock_year.assert_called_once_with(mock_service.id, datetime.now().year)
mock_year.assert_called_once_with(
mock_service.id,
get_current_financial_year(),
)

0 comments on commit 99133d9

Please sign in to comment.