Skip to content

Commit 98930a1

Browse files
authored
Merge pull request #476 from NHSDigital/improve-create-appointments-logged-output
Improve logging output from Create Appointments command
2 parents d091bd5 + 294d028 commit 98930a1

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

manage_breast_screening/notifications/management/commands/create_appointments.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ def add_arguments(self, parser):
3535

3636
def handle(self, *args, **options):
3737
try:
38-
logger.info("Create Appointments Command started")
38+
logger.info("Create Appointments command started")
3939
container_client = BlobStorage().find_or_create_container(
4040
os.getenv("BLOB_CONTAINER_NAME")
4141
)
4242
for blob in container_client.list_blobs(
4343
name_starts_with=options["date_str"]
4444
):
4545
blob_client = container_client.get_blob_client(blob.name)
46-
logger.debug(f"Processing blob {blob.name}")
46+
logger.debug("Processing blob %s", blob.name)
4747
blob_content = blob_client.download_blob(
4848
max_concurrency=1, encoding="ASCII"
4949
).readall()
@@ -60,11 +60,13 @@ def handle(self, *args, **options):
6060
row, clinic
6161
)
6262
logger.info(
63-
f"{appt} {'created' if appt_created else 'updated'}"
63+
"%s %s", appt, ("created" if appt_created else "updated")
6464
)
6565

66-
self.stdout.write(f"Processed {len(data_frame)} rows from {blob.name}")
66+
logger.info("Processed %s rows from %s", len(data_frame), blob.name)
67+
logger.info("Create Appointments command finished successfully")
6768
except Exception as e:
69+
logger.error(e, exc_info=True)
6870
raise CommandError(e)
6971

7072
def is_not_holding_clinic(self, row):

manage_breast_screening/notifications/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import uuid
2+
from zoneinfo import ZoneInfo
23

34
from django.db import models
45

@@ -137,8 +138,11 @@ class Meta:
137138

138139
clinic = models.ForeignKey("notifications.Clinic", on_delete=models.PROTECT)
139140

141+
def localised_starts_at(self):
142+
return self.starts_at.replace(tzinfo=ZoneInfo("Europe/London"))
143+
140144
def __str__(self):
141-
return f"Appointment for {self.starts_at} at {self.clinic}"
145+
return f"Appointment {self.nbss_id} for {self.localised_starts_at()} at {self.clinic}"
142146

143147

144148
class Clinic(models.Model):

0 commit comments

Comments
 (0)