From e774ed833bcd460fd4defae0c0808df422e109bc Mon Sep 17 00:00:00 2001 From: "Andreas (@xAndy) Zimmermann" Date: Sat, 13 May 2023 15:13:51 +0200 Subject: [PATCH] more equality --- shiftregister/fallback/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shiftregister/fallback/models.py b/shiftregister/fallback/models.py index 2132bf9..c4bbf40 100644 --- a/shiftregister/fallback/models.py +++ b/shiftregister/fallback/models.py @@ -84,9 +84,10 @@ class TeamMember(models.Model): distinct=True, filter=Q(fallback_shifts__id__in=canidate_shift_ids), ), + overall_fallback_count=Count("fallback_shifts"), ) .exclude(pk=self.pk) - .order_by("-relevant_fallback_count", "?") + .order_by("-relevant_fallback_count", "-overall_fallback_count", "?") ) assignment = False for member in sorted_members: