Skip to content

Commit b2aa2e9

Browse files
committed
Report updated rows.
1 parent 1fd0a1f commit b2aa2e9

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

app/grandchallenge/utilization/management/commands/link_challenge_utilization_to_invoice.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ def handle(self, *_, **__):
3333
challenge_count = Challenge.objects.count()
3434

3535
for indx, challenge in enumerate(Challenge.objects.all()):
36+
prefix = f"[{challenge.short_name}]"
3637
self.stdout.write(
3738
self.style.SUCCESS(
38-
f"Working on linking utilizations for {challenge.short_name!r} ({indx + 1}/{challenge_count})."
39+
f"{prefix} Working on linking utilizations for ({indx + 1}/{challenge_count})."
3940
)
4041
)
4142
try:
@@ -44,21 +45,28 @@ def handle(self, *_, **__):
4445
missing_invoice_challenges.append(challenge.short_name)
4546
self.stdout.write(
4647
self.style.WARNING(
47-
f"No invoices found for {challenge.short_name!r}, skipping."
48+
f"{prefix} No invoices found, skipping."
4849
)
4950
)
5051
else:
5152
for model in CHALLENGE_UTILIZATION_MODELS:
52-
model.objects.filter(
53+
rows_updated = model.objects.filter(
5354
challenge=challenge,
5455
invoice__isnull=True,
5556
).update(invoice=invoice)
56-
57-
self.stdout.write(
58-
self.style.SUCCESS(
59-
f"Finished linking utilizations. Total challenges: {challenge_count}."
57+
if rows_updated:
58+
self.stdout.write(
59+
self.style.WARNING(
60+
f"{prefix} {rows_updated} {model.__name__} updated."
61+
)
62+
)
63+
self.stdout.write(
64+
self.style.SUCCESS(
65+
f"{prefix} Finished linking utilizations ({indx + 1}/{challenge_count})."
66+
)
6067
)
61-
)
68+
69+
self.stdout.write(self.style.SUCCESS("Finished linking utilizations."))
6270

6371
if missing_invoice_challenges:
6472
self.stdout.write(

0 commit comments

Comments
 (0)