feat: add condition to check for week-day combinations before adding constraints in RotaBuilder

This commit is contained in:
Ross
2026-07-09 22:39:38 +01:00
parent b5525bd3fb
commit d1fbbe2dc9
+12 -11
View File
@@ -2788,18 +2788,19 @@ class RotaBuilder(object):
"target_shifts": target_shifts, "target_shifts": target_shifts,
} }
self.model.constraints.add( if self.get_week_day_combinations_for_shift(shift):
inequality( self.model.constraints.add(
min_shifts, inequality(
sum( min_shifts,
self.model.works[worker.id, week, day, shift.name] sum(
for week, day in self.get_week_day_combinations_for_shift( self.model.works[worker.id, week, day, shift.name]
shift for week, day in self.get_week_day_combinations_for_shift(
) shift
), )
max_shifts, ),
max_shifts,
)
) )
)
else: else:
# Make sure shifts aren't assigned to those from other sites # Make sure shifts aren't assigned to those from other sites
# Not needed if there are no shifts # Not needed if there are no shifts