feat: add max days per week block constraint to Worker class
- Introduced a new method `add_max_days_per_week_block_constraint` to the Worker class. - This method allows for the addition of constraints that limit the number of days a worker can be assigned within a specified sliding block of weeks. - The method accepts parameters for maximum days, the week block size, and optional dates to ignore.
This commit is contained in:
@@ -552,3 +552,7 @@ class Worker(BaseModel):
|
||||
def force_assign_shift_by_date(self, date: datetime.date, shift_name: str):
|
||||
"""Force this worker to be assigned to a shift on a specific date."""
|
||||
self.forced_assignments_by_date.append((date, shift_name))
|
||||
|
||||
def add_max_days_per_week_block_constraint(self, max_days: int, week_block: int, ignore_dates: Optional[List[datetime.date]] = None):
|
||||
"""Add a constraint to limit the number of days worked in any sliding block of weeks."""
|
||||
self.max_days_per_week_block.append(MaxDaysPerWeekBlockConstraint(max_days=max_days, week_block=week_block, ignore_dates=ignore_dates or []))
|
||||
|
||||
Reference in New Issue
Block a user