Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/staff/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ class AssignedOrderTable(StatusMixinTable, StaffIDMixinTable):

samples_completed = tables.Column(
accessor="sample_count",
verbose_name="Samples completed",
verbose_name="Samples isolated",
orderable=False,
)

Expand Down
30 changes: 24 additions & 6 deletions src/staff/templatetags/order_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,17 @@ def new_seen_orders_table(context: dict, area: Area | None = None) -> dict:
.exclude(is_urgent=True)
.select_related("genrequest")
.annotate(
sample_count=models.Count("extractionorder__samples"),
sample_count=models.Case(
models.When(
extractionorder__isnull=False,
then=models.Count("extractionorder__samples", distinct=True),
),
models.When(
analysisorder__isnull=False,
then=models.Count("analysisorder__samples", distinct=True),
),
default=0,
),
priority=models.Case(
models.When(is_urgent=True, then=Order.OrderPriority.URGENT),
models.When(is_prioritized=True, then=Order.OrderPriority.PRIORITIZED),
Expand Down Expand Up @@ -84,7 +94,17 @@ def new_unseen_orders_table(context: dict, area: Area | None = None) -> dict:
.exclude(is_urgent=True)
.select_related("genrequest")
.annotate(
sample_count=models.Count("extractionorder__samples"),
sample_count=models.Case(
models.When(
extractionorder__isnull=False,
then=models.Count("extractionorder__samples", distinct=True),
),
models.When(
analysisorder__isnull=False,
then=models.Count("analysisorder__samples", distinct=True),
),
default=0,
)
)
.prefetch_related(
"analysisorder__markers",
Expand Down Expand Up @@ -116,14 +136,12 @@ def assigned_orders_table(context: dict) -> dict:
)
.select_related("genrequest")
.annotate(
sample_count=models.Count("extractionorder__samples"),
)
.annotate(
sample_count=models.Count("extractionorder__samples", distinct=True),
priority=models.Case(
models.When(is_urgent=True, then=Order.OrderPriority.URGENT),
models.When(is_prioritized=True, then=Order.OrderPriority.PRIORITIZED),
default=1,
)
),
)
.order_by(
models.Case(
Expand Down