RFC 001 - Scheduling #35
Labels
area:logic
Related to generating Essence and other business logic of the app
area:ui
Related to Svelte UI components
rfc
Request for comment. Used for detailed planning & discussion of planned features and changes
Overview
This RFC defines the new format for representing information about
Tasks
,Shifts
and the assignment ofEmployees
toTasks
, including the handling of date/time and recurrence information forShifts
, type definitions for the newAssignment
,Task
andShift
objects, serialisation / deserialisation of these objects, and their representation in the UI.Its aims are to:
Shifts
and the assignment of employees to tasksIntroduction
The main purpose of this app is to compute an optimal assignment of employees to tasks while satisfying a set of user-defined constraints, using a constraints solver.
As such, given the following set of facts:
Employees
, with relevant information about them (e.g. their qualification)Tasks
, that represent a general kind of work that needs to be doneLocations
, that represent offices, buildings and other physical places where tasks can be done (See: TODO Locations RFC)Shifts
, that represent a set ofTasks
being done during specific recurring periods of timeEmployees
toTasks
during a specific shiftAs well as:
Constraints
, that represent user-defined rules operating on the above objects that need to be satisfied. (See: TODO Constraints RFC)The goal is to find a complete assignment for a given time period, such that:
Tasks
for every occurrence of every shift have at least the minimum number ofEmployees
assigned to themConstraints
are satisfiedRequirements
As part of this, the following problems need to be solved:
Shifts
- a recurring schedule for when they take place, as well as their duration.For example:
Tasks
A, B, C, D"Constraints
, such that a constraint can apply:Shift
Shifts
(ever; regardless of which shift Task B is part of or the date when it occurs)
(this applies to all Night Shifts on all days, but does not apply to other shifts on the same day)
(this applies weekly on every Monday - John cannot be assigned to any
Task
of anyShift
on these days)(this applies every day within a specified time period, but does not apply for the rest of the scheduling period)
Shifts
(e.g: "Tasks
A, B need to be done from 9:00 to 17:00 every weekday") to specificAssignments
(e.g.: "Jane is doing Task A on Monday at Office 1, and there are 2 more unfilled slots for this task, at this location, at this time")The solution needs to be flexible to accommodate different approaches to scheduling that can exist in different industries
Design
The core ideas are to:
Tasks
(which will now represent a generic kind of work that needs to be done, with no temporal or assignment information)Shifts
(which define recurring schedules for a set of tasks)Assignments
(which represent specificEmployees
doing specificTasks
at a specificLocation
doing a specific non-recurring period of time - i.e. an "occurrence" of aShift
)Shifts
andConstraints
Assignments
reference aShift
object, along with a number representing then
-th occurrence of theShift
Assignments
forShifts
, create them as needed and only store the non-empty ones.(Empty assignments can be added as needed when passing data to the solver)
Shifts
Tasks
andAssignments
within one specificShift
, and editing the assignmentsThis approach:
Assignments
fromTasks
andShifts
, such that different people can be assigned to different tasks on different days, but their date/time is still tied directly to the shift's schedule(Thus, when the shift is rescheduled, all
Assignment
information automatically updates with it)Examples
Note
Types in these examples have been simplified; Full and accurate type definitions are given bellow
Recurrence Example
Let Shift 1 has the following properties:
"A", "B"
rrule
:occurrences
of the shift can be easily computed by adding the duration:Assignment Example
This assignment refers to the 2nd occurrence of
dayShift
, i.e. the time period of 10:30 - 18:30 on 12.02.2024.It represents the fact that Alice and Bob have been assigned to do Task A during this time as part of the shift Shift 1, and that they are working at Office 1.
Types
Serialisation / Deserialisation
Note
Assignments
,Tasks
andShifts
need to be serialisable to be stored in local storage. Unless we write custom serialisation / deserialisation code for all of them (and maintain it as the types change), we can only use interfaces with primitive types orDates
as their fields - these can be serialised and parsed by devalue as is, without any extra configurationTime
A helper type to represent a duration of time
Task
The
Task
type will no longer contain a list of people assigned to it. Other fields remain unchanged:New functions will be added to access
Shifts
andAssignments
that reference aTask
:Note
Since
rrule
will be evaluated dynamically when fetching the assignments, we have to specify a time period, otherwise the recurrence may be infinite.inShifts
is an optional parameter to restrict the search to specific shifts, for performance reasons (evaluatingrrule
's can be expensive)Assignment
The
Assignment
type will now reference only oneTask
(not a list of them), and will not contain any temporal information of its own. Instead, it would reference aShift
and contain the number of theShift
's occurrence for which it is scheduled.It may also contain the optional parameters
start_offset
(allowing theAssignment
to start later than the shift starts) andend_offset
(allowing theAssignment
to end earlier than the shift starts). If not specified, these are assumed to be 0.Shift
A shift defines a recurring schedule on which certain
Tasks
need to be done.UI
Assignments
Shifts
Weekly
andDaily
recurrence patterns should be supported by the UI. An existingrrule
component can be used to generate the recurrence rules for shifts.Dragging shift occurrences would reschedule them (and other shifts in their series), and vertically dragging them would change their start time and duration
The text was updated successfully, but these errors were encountered: