Skip to content

Commit

Permalink
Fix list_transactions for the case when workbaskets are empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuaxo committed Aug 26, 2022
1 parent f03bc89 commit 3ad256c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions pii-ner-exclude.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1168,3 +1168,4 @@ measure_qs)\n
MeasureComponent
Components
TP2000-452
WorkBasketOutputFormat Enum
17 changes: 14 additions & 3 deletions workbaskets/management/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ def _output_workbasket_readable(
self.stdout.write(f"{spaces}reason: {first_line_of(workbasket.reason)}")
self.stdout.write(f"{spaces}status: {workbasket.status}")
if show_transaction_info:
transactions = workbasket.transactions
first_pk = (
workbasket.transactions.first().pk if transactions.count() else "-"
)
last_pk = workbasket.transactions.last().pk if transactions.count() else "-"

self.stdout.write(
f"{spaces}transactions: {workbasket.transactions.first().pk} - {workbasket.transactions.last().pk}",
f"{spaces}transactions: {first_pk} - {last_pk} [{transactions.count()}]",
)

def _output_workbasket_compact(self, workbasket, show_transaction_info, **kwargs):
Expand All @@ -32,14 +38,19 @@ def _output_workbasket_compact(self, workbasket, show_transaction_info, **kwargs
ending="" if show_transaction_info else "\n",
)
if show_transaction_info:
transactions = workbasket.transactions
first_pk = (
workbasket.transactions.first().pk if transactions.count() else "-"
)
last_pk = workbasket.transactions.last().pk if transactions.count() else "-"
self.stdout.write(
f", {workbasket.transactions.first().pk} - {workbasket.transactions.last().pk}",
f", {first_pk} - {last_pk} [{transactions.count()}]",
)

def output_workbasket(
self,
workbasket,
show_transaction_info=False,
show_transaction_info,
output_format=WorkBasketOutputFormat.READABLE,
**kwargs,
):
Expand Down

0 comments on commit 3ad256c

Please sign in to comment.