Merge branch 'master' of git.xkjq.uk:30001]:ross/proc-rota
This commit is contained in:
+2
-1
@@ -74,6 +74,7 @@ Rota.constraint_options["prevent_thursdays_before_full_weekends"] = [
|
|||||||
"exeter",
|
"exeter",
|
||||||
"truro no proc",
|
"truro no proc",
|
||||||
]
|
]
|
||||||
|
Rota.constraint_options["require_presence_at_site_overnight"] = ["plymouth"]
|
||||||
|
|
||||||
Rota.add_shifts(
|
Rota.add_shifts(
|
||||||
SingleShift(
|
SingleShift(
|
||||||
@@ -322,7 +323,7 @@ else:
|
|||||||
oop,
|
oop,
|
||||||
not_available_to_work=leave_requests,
|
not_available_to_work=leave_requests,
|
||||||
work_requests=work_requests,
|
work_requests=work_requests,
|
||||||
proc_site=site_pref,
|
night_site=site_pref,
|
||||||
previous_shifts=previous_shifts,
|
previous_shifts=previous_shifts,
|
||||||
pair=pair,
|
pair=pair,
|
||||||
shift_balance_extra=w["shift_balance_extra"],
|
shift_balance_extra=w["shift_balance_extra"],
|
||||||
|
|||||||
@@ -181,6 +181,8 @@ class RotaBuilder(object):
|
|||||||
"prevent_monday_and_tuesday_after_full_weekends": [],
|
"prevent_monday_and_tuesday_after_full_weekends": [],
|
||||||
"prevent_fridays_before_full_weekends": [],
|
"prevent_fridays_before_full_weekends": [],
|
||||||
"prevent_thursdays_before_full_weekends": [],
|
"prevent_thursdays_before_full_weekends": [],
|
||||||
|
# This may be better defined on the shift?
|
||||||
|
"require_presence_at_site_overnight": [],
|
||||||
"avoid_st2_first_month": False,
|
"avoid_st2_first_month": False,
|
||||||
"hard_constrain_pair_separation": False,
|
"hard_constrain_pair_separation": False,
|
||||||
}
|
}
|
||||||
@@ -739,24 +741,47 @@ class RotaBuilder(object):
|
|||||||
rule=nightShiftMinST4Rule,
|
rule=nightShiftMinST4Rule,
|
||||||
)
|
)
|
||||||
|
|
||||||
def nightShiftDerrifordRule(model, week, shift):
|
# def nightShiftDerrifordRule(model, week, shift):
|
||||||
derriford_workers = [w for w in self.workers if w.night_at_derriford >= 1]
|
# derriford_workers = [w for w in self.workers if w.night_at_derriford >= 1]
|
||||||
# if not derriford_workers:
|
# # if not derriford_workers:
|
||||||
# return Constraint.Skip
|
# # return Constraint.Skip
|
||||||
|
# return (
|
||||||
|
# sum(
|
||||||
|
# model.shift_week_worker_assigned[shift, week, w.id]
|
||||||
|
# for w in derriford_workers
|
||||||
|
# )
|
||||||
|
# >= 1
|
||||||
|
# )
|
||||||
|
|
||||||
|
# if self.constraint_options["ensure_derriford_reg_for_nights"]:
|
||||||
|
# self.model.night_shifts_derriford_rule = Constraint(
|
||||||
|
# [week for week in self.weeks],
|
||||||
|
# [shift.name for shift in self.get_shifts_with_constraint("night")],
|
||||||
|
# rule=nightShiftDerrifordRule,
|
||||||
|
# )
|
||||||
|
|
||||||
|
def presenceAtSiteOvernight(model, week, shift, required_site):
|
||||||
|
required_site_workers = [
|
||||||
|
w for w in self.workers if required_site == w.night_site
|
||||||
|
]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
sum(
|
sum(
|
||||||
model.shift_week_worker_assigned[shift, week, w.id]
|
model.shift_week_worker_assigned[shift, week, w.id]
|
||||||
for w in derriford_workers
|
for w in required_site_workers
|
||||||
)
|
)
|
||||||
>= 1
|
>= 1
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.constraint_options["ensure_derriford_reg_for_nights"]:
|
if self.constraint_options["require_presence_at_site_overnight"]:
|
||||||
self.model.night_shifts_derriford_rule = Constraint(
|
|
||||||
[week for week in self.weeks],
|
for site in self.constraint_options["require_presence_at_site_overnight"]:
|
||||||
[shift.name for shift in self.get_shifts_with_constraint("night")],
|
self.model.require_presence_at_site_overnight_rule = Constraint(
|
||||||
rule=nightShiftDerrifordRule,
|
[week for week in self.weeks],
|
||||||
)
|
[shift.name for shift in self.get_shifts_with_constraint("night")],
|
||||||
|
[site],
|
||||||
|
rule=presenceAtSiteOvernight,
|
||||||
|
)
|
||||||
|
|
||||||
# # Count the number of workers from each site on each night shift
|
# # Count the number of workers from each site on each night shift
|
||||||
# # As 1 or 0 is optimum we can simply subtract 1 from the number
|
# # As 1 or 0 is optimum we can simply subtract 1 from the number
|
||||||
|
|||||||
+3
-3
@@ -20,7 +20,7 @@ class Worker:
|
|||||||
not_available_to_work=None,
|
not_available_to_work=None,
|
||||||
pref_not_to_work=None,
|
pref_not_to_work=None,
|
||||||
work_requests=None,
|
work_requests=None,
|
||||||
proc_site: str = "plymouth", # We set a default proc_site
|
night_site: str = "plymouth", # We set a default proc_site
|
||||||
previous_shifts: dict = {},
|
previous_shifts: dict = {},
|
||||||
shift_balance_extra: dict = {},
|
shift_balance_extra: dict = {},
|
||||||
bank_holiday_extra: int = 0,
|
bank_holiday_extra: int = 0,
|
||||||
@@ -44,8 +44,8 @@ class Worker:
|
|||||||
self.shift_balance_extra = shift_balance_extra
|
self.shift_balance_extra = shift_balance_extra
|
||||||
self.bank_holiday_extra = bank_holiday_extra
|
self.bank_holiday_extra = bank_holiday_extra
|
||||||
|
|
||||||
self.proc_site = proc_site
|
self.proc_site = night_site
|
||||||
if proc_site == "plymouth" or proc_site == "":
|
if night_site == "plymouth" or night_site == "":
|
||||||
self.night_at_derriford = 1
|
self.night_at_derriford = 1
|
||||||
else:
|
else:
|
||||||
self.night_at_derriford = 0
|
self.night_at_derriford = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user