Skip to content

Matching Logic

Ryan Mahoney edited this page Sep 24, 2018 · 3 revisions

Alert Matching

The process of choosing which alerts to send to a subscriber based on a set of rules is referred to as matching.

Alerts and subscriptions each have many attributes. Some of these attributes are provided to each stage of the rule system to attempt to disqualify a notification. A notification is created when all rules have been satisfied.

Rule 1: Alert Check

If an alert does not have a value for the attributes: last_push_notification_timestamp or active_period, then that alert is excluded from matching any subscriptions.

Rule 2: Duplicate Check

If a subscriber has already received a particular alert, they will not receive it again unless the last_push_notification_timestamp has been augmented.

Rule 3: Network Check (Informed Entities)

Parts of the transit network are referenced by informed entities. Alerts and subscriptions each contain informed entities.

Informed entities are considered a match when:

  • The alert and subscription informed entity has a value for the same attribute
  • The alert and/or subscription informed entity has a nil value for an attribute
  • At least one non-nil match was found for an attribute attribute

A list of informed entities with example values is located after the rules.

Rule 5: Time Check

Subscription.relevant_days, start_time and end_time are compared with the Alert.active_periods.


Informed Entity Attributes

Attribute Example
route_type subway, bus, commuter_rail, ferry
route Red, 742, CR-Fairmount, Boat-F4
direction_id 0 or 1
stop Place-brntn
trip 339, Boat-F4-Boat-Charlestown-08:00:00-weekday-1
activities BOARD, EXIT, RIDE
facility_type elevator
schedule A combination of departure_time, stop_id and trip_id

Clone this wiki locally