feat(fallback): assign restricted shifts from their own bucket
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Luca 2025-05-17 20:11:47 +02:00
parent d7d26c56b0
commit 38cdbec9fa
1 changed files with 6 additions and 1 deletions

View File

@ -40,7 +40,9 @@ class TeamMember(models.Model):
return urlsafe_b64encode(self.id.to_bytes(3, byteorder="big")).decode("utf-8") return urlsafe_b64encode(self.id.to_bytes(3, byteorder="big")).decode("utf-8")
def assign_random_shifts(self): def assign_random_shifts(self):
needs_fallback = Q(deleted=False, calendar__needs_fallback=True) needs_fallback = Q(
deleted=False, calendar__needs_fallback=True, calendar__restricted=False
)
current_tz = timezone.get_current_timezone() current_tz = timezone.get_current_timezone()
# create a datetime combining the last date having fallback shifts # create a datetime combining the last date having fallback shifts
@ -67,6 +69,9 @@ class TeamMember(models.Model):
self._assign_from_bucket(night_shifts) self._assign_from_bucket(night_shifts)
self._assign_from_bucket(shit_shifts) self._assign_from_bucket(shit_shifts)
for calendar in Calendar.objects.filter(needs_fallback=True, restricted=True):
self._assign_from_bucket(Q(deleted=False, calendar=calendar))
def _assign_from_bucket(self, bucket_selector): def _assign_from_bucket(self, bucket_selector):
bucket = Event.objects.filter(bucket_selector).annotate( bucket = Event.objects.filter(bucket_selector).annotate(
fallback_count=Count("fallbackassignment"), fallback_count=Count("fallbackassignment"),