activity.matching.score

Classes

Scoring

Provides scoring based on a number of criteria.

PreferMotivated

Scores "motivated" bookings higher. A motivated booking is simply a

PreferInAgeBracket

Scores bookings whose attendees fall into the age-bracket of the

PreferOrganiserChildren

Scores bookings of children higher if their parents are organisers.

PreferAdminChildren

Scores bookings of children higher if their parents are admins.

PreferGroups

Scores group bookings higher than other bookings. Groups get a boost

Module Contents

class activity.matching.score.Scoring(criteria: list[Callable[[Booking], float]] | None = None)[source]

Provides scoring based on a number of criteria.

A criteria is a callable which takes a booking and returns a score. The final score is the sum of all criteria scores.

criteria: list[Callable[[Booking], float]][source]
__call__(booking: onegov.activity.models.Booking) decimal.Decimal[source]
classmethod from_settings(settings: dict[str, Any], session: sqlalchemy.orm.Session) Self[source]
property settings: dict[str, Any][source]
class activity.matching.score.PreferMotivated[source]

Scores “motivated” bookings higher. A motivated booking is simply a booking with a higher priority (an attendee would favor a booking he’s excited about.)

classmethod from_session(session: sqlalchemy.orm.Session) Self[source]
__call__(booking: onegov.activity.models.Booking) int[source]
class activity.matching.score.PreferInAgeBracket(get_age_range: Callable[[Booking], tuple[int, int]], get_attendee_age: Callable[[Booking], int])[source]

Scores bookings whose attendees fall into the age-bracket of the occasion higher.

If the attendee falls into the age-bracket, the score is 1.0. Each year difference results in a penalty of 0.1, until 0.0 is reached.

get_age_range[source]
get_attendee_age[source]
classmethod from_session(session: sqlalchemy.orm.Session) Self[source]
__call__(booking: onegov.activity.models.Booking) float[source]
class activity.matching.score.PreferOrganiserChildren(get_is_organiser_child: Callable[[Booking], bool])[source]

Scores bookings of children higher if their parents are organisers.

This is basically an incentive to become an organiser. A child whose parent is an organiser gets a score of 1.0, if the parent is not an organiser a score 0.0 is returned.

get_is_organiser_child[source]
classmethod from_session(session: sqlalchemy.orm.Session) Self[source]
__call__(booking: onegov.activity.models.Booking) float[source]
class activity.matching.score.PreferAdminChildren(get_is_association_child: Callable[[Booking], bool])[source]

Scores bookings of children higher if their parents are admins.

get_is_association_child[source]
classmethod from_session(session: sqlalchemy.orm.Session) Self[source]
__call__(booking: onegov.activity.models.Booking) float[source]
class activity.matching.score.PreferGroups(get_group_score: Callable[[Booking], float])[source]

Scores group bookings higher than other bookings. Groups get a boost by size:

  • 2 people: 1.0

  • 3 people: 0.8

  • 4 people: 0.6

  • more people: 0.5

This preference gives an extra boost to unprioritised bookings, to somewhat level out bookings in groups that used no star (otherwise a group might be split up because someone didn’t star the booking).

Additionally a unique boost between 0.010000000 to 0.099999999 is given to each group depending on the group name. This should ensure that competing groups generally do not have the same score. So an occasion will generally prefer the members of one group over members of another group.

get_group_score[source]
classmethod from_session(session: sqlalchemy.orm.Session) Self[source]
__call__(booking: onegov.activity.models.Booking) float[source]