activity.matching.utils
Attributes
Classes
Helps ensure that a loop doesn't overreach its complexity budget. |
|
Functions
|
Returns true if the given booking overlaps with the given booking |
|
Keeps the bookings predictably sorted from highest to lowest priority. |
|
Returns a set of items in the blocked set which do not block |
Module Contents
- activity.matching.utils.overlaps(booking: onegov.activity.models.Booking, other: Booking | Occasion, minutes_between: float = 0, alignment: Literal['day', 'week', 'month'] | None = None, with_anti_affinity_check: bool = False) bool [source]
Returns true if the given booking overlaps with the given booking or occasion.
- class activity.matching.utils.LoopBudget(max_ticks: int)[source]
Helps ensure that a loop doesn’t overreach its complexity budget.
For example:
budget = LoopBudget(max_ticks=10) while True: if budget.limit_reached(): break
- activity.matching.utils.booking_order(booking: onegov.activity.models.Booking) tuple[decimal.Decimal, int, uuid.UUID] [source]
Keeps the bookings predictably sorted from highest to lowest priority.
- activity.matching.utils.unblockable(accepted: Iterable[Booking], blocked: Iterable[Booking], key: Callable[[Booking], OrderT] = booking_order, with_anti_affinity_check: bool = False) SortedKeySet[Booking, OrderT] [source]
Returns a set of items in the blocked set which do not block with anything. The set is ordered using
booking_order()
.