Implement hard day exclusions for workers and add corresponding tests
This commit is contained in:
+15
-6
@@ -266,7 +266,7 @@ def load_workers():
|
||||
week=assignment["week"],
|
||||
day=assignment["day"],
|
||||
shift_name=assignment["shift"],
|
||||
)
|
||||
)
|
||||
if initial in rota_b_assignments:
|
||||
for date in rota_b_assignments.get(initial, []):
|
||||
w.force_assign_shift_by_date(
|
||||
@@ -285,6 +285,14 @@ def load_workers():
|
||||
w.add_hard_day_dependency({"Fri", "Sat", "Sun"}, start_date="2025-11-17")
|
||||
else:
|
||||
w.add_hard_day_dependency({"Fri", "Sun"}, start_date="2025-11-17")
|
||||
w.add_hard_day_exclusion({"Sat", "Sun"}, start_date="2025-11-17")
|
||||
|
||||
|
||||
#if w.name == "TB":
|
||||
# w.add_hard_day_exclusion({"Sat", "Sun"}, start_date="2025-11-17")
|
||||
|
||||
|
||||
#w.set_max_shifts
|
||||
#w.set_max_shifts_per_week("weekend", 1)
|
||||
|
||||
workers.append(w)
|
||||
@@ -316,6 +324,7 @@ def main(
|
||||
Rota.constraint_options["balance_weekends"] = True
|
||||
#Rota.constraint_options["max_weekend_frequency"] = 2
|
||||
Rota.constraint_options["max_shifts_per_week"] = 6
|
||||
Rota.constraint_options["max_days_worked_per_week"] = 3
|
||||
# Rota.constraint_options["avoid_st2_first_month"] = True
|
||||
|
||||
Rota.add_shifts(
|
||||
@@ -342,7 +351,7 @@ def main(
|
||||
balance_offset=1,
|
||||
constraint=[
|
||||
#{"name": "pre", "options": 2},
|
||||
#{"name": "post", "options": 1},
|
||||
{"name": "post", "options": 1},
|
||||
],
|
||||
display_char="a",
|
||||
#force_assign_with=["oncall"]
|
||||
@@ -371,10 +380,10 @@ def main(
|
||||
length=12.5,
|
||||
days=days[:5],
|
||||
balance_offset=1,
|
||||
#constraint=[
|
||||
# {"name": "pre", "options": 1},
|
||||
# {"name": "post", "options": 1},
|
||||
#],
|
||||
constraint=[
|
||||
#{"name": "pre", "options": 1},
|
||||
#{"name": "post", "options": 1},
|
||||
],
|
||||
),
|
||||
)
|
||||
#Rota.allow_shifts_together_for_all_workers(
|
||||
|
||||
Reference in New Issue
Block a user