Skip to content

Commit 9b236b2

Browse files
authored
Debug annual limits (#364)
* Add debug logging * fix logging * Remove excessive logging, added specific logging for staging test
1 parent 3cba68a commit 9b236b2

4 files changed

Lines changed: 20 additions & 6 deletions

File tree

.github/actions/waffles/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ docopt==0.6.2
22
Flask==2.3.3
33
markupsafe==2.1.5
44
setuptools==75.6.0 # required for distutils in Python 3.12
5-
git+https://github.com/cds-snc/notifier-utils.git@53.2.1#egg=notifications-utils
5+
git+https://github.com/cds-snc/notifier-utils.git@53.2.2#egg=notifications-utils

notifications_utils/clients/redis/annual_limit.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,12 @@ def seed_annual_limit_notifications(self, service_id: str, mapping: dict):
244244
current_app.logger.warning(f"Missing V2 fields when seeding annual limit for service {service_id}: {missing_fields}")
245245

246246
# Store V2 fields
247-
v2_result = self._redis_client.bulk_set_hash_fields(key=annual_limit_notifications_v2_key(service_id), mapping=v2_mapping)
247+
current_app.logger.info(
248+
f"[alimit-debug-redis] Setting notification_v2 values for service_id: {service_id} with mapping: {v2_mapping}"
249+
)
250+
self._redis_client.bulk_set_hash_fields(key=annual_limit_notifications_v2_key(service_id), mapping=v2_mapping)
251+
v2_values = prepare_byte_dict(self._redis_client.get_all_from_hash(annual_limit_notifications_v2_key(service_id)), str)
252+
current_app.logger.info(f"[alimit-debug-redis] Finished setting values, result is: {v2_values}")
248253

249254
# Create a legacy mapping from either original legacy keys or mapped from V2 keys
250255
legacy_mapping = {}
@@ -268,9 +273,11 @@ def seed_annual_limit_notifications(self, service_id: str, mapping: dict):
268273
if legacy_mapping:
269274
self._redis_client.bulk_set_hash_fields(key=annual_limit_notifications_key(service_id), mapping=legacy_mapping)
270275

271-
# Only after successful storage, set the seeded flag
272-
if v2_result:
273-
self.set_seeded_at(service_id)
276+
current_app.logger.info(f"[alimit-debug-redis] Setting seeded_at for service {service_id}")
277+
self.set_seeded_at(service_id)
278+
current_app.logger.info(
279+
f"[alimit-debug-redis] Finished setting seeded_at, new value is: {self.get_seeded_at(service_id)}"
280+
)
274281

275282
def was_seeded_today(self, service_id):
276283
last_seeded_time = self.get_seeded_at(service_id)

notifications_utils/clients/redis/redis_client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,16 @@ def bulk_set_hash_fields(self, mapping, pattern=None, key=None, raise_exception=
125125
if self.active:
126126
try:
127127
if pattern:
128+
current_app.logger.info(
129+
f"[alimit-debug-redis] bulk_set_hash_fields - Pattern branch. pattern: {pattern}, key: {key}, mapping: {mapping}"
130+
)
128131
for key in self.redis_store.scan_iter(pattern):
129132
self.redis_store.hmset(key, mapping)
133+
return True
130134
if key:
135+
current_app.logger.info(
136+
f"[alimit-debug-redis] bulk_set_hash_fields - key branch. pattern: {pattern}, key: {key}, mapping: {mapping}"
137+
)
131138
return self.redis_store.hmset(key, mapping)
132139
except Exception as e:
133140
self.__handle_exception(e, raise_exception, "bulk_set_hash_fields", pattern)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "notifications-utils"
3-
version = "53.2.1"
3+
version = "53.2.2"
44
description = "Shared python code for Notification - Provides logging utils etc."
55
authors = ["Canadian Digital Service"]
66
license = "MIT license"

0 commit comments

Comments
 (0)