activity.matching.utils ======================= .. py:module:: activity.matching.utils Attributes ---------- .. autoapisummary:: activity.matching.utils.OrderT Classes ------- .. autoapisummary:: activity.matching.utils.LoopBudget activity.matching.utils.HashableID Functions --------- .. autoapisummary:: activity.matching.utils.overlaps activity.matching.utils.booking_order activity.matching.utils.unblockable Module Contents --------------- .. py:data:: OrderT .. py:function:: overlaps(booking: onegov.activity.models.Booking, other: onegov.activity.models.Booking | onegov.activity.models.Occasion, minutes_between: float = 0, alignment: Literal['day', 'week', 'month'] | None = None, with_anti_affinity_check: bool = False) -> bool Returns true if the given booking overlaps with the given booking or occasion. .. py:class:: LoopBudget(max_ticks: int) 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 .. py:attribute:: ticks :value: 0 .. py:attribute:: max_ticks .. py:method:: limit_reached(as_exception: bool = False) -> bool | None .. py:class:: HashableID .. py:attribute:: id :type: collections.abc.Hashable .. py:method:: __hash__() -> int .. py:method:: __eq__(other: object) -> bool .. py:function:: booking_order(booking: onegov.activity.models.Booking) -> tuple[decimal.Decimal, int, uuid.UUID] Keeps the bookings predictably sorted from highest to lowest priority. .. py:function:: unblockable(accepted: collections.abc.Iterable[onegov.activity.models.Booking], blocked: collections.abc.Iterable[onegov.activity.models.Booking], key: collections.abc.Callable[[onegov.activity.models.Booking], OrderT] = booking_order, with_anti_affinity_check: bool = False) -> sortedcontainers.sortedset.SortedKeySet[onegov.activity.models.Booking, OrderT] Returns a set of items in the blocked set which do not block with anything. The set is ordered using :func:`booking_order`.