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,
}
self.model.constraints.add(
inequality(
min_shifts,
sum(
self.model.works[worker.id, week, day, shift.name]
for week, day in self.get_week_day_combinations_for_shift(
shift
)
),
max_shifts,
if self.get_week_day_combinations_for_shift(shift):
self.model.constraints.add(
inequality(
min_shifts,
sum(
self.model.works[worker.id, week, day, shift.name]
for week, day in self.get_week_day_combinations_for_shift(
shift
)
),
max_shifts,
)
)
)
else:
# Make sure shifts aren't assigned to those from other sites
# Not needed if there are no shifts