-
Notifications
You must be signed in to change notification settings - Fork 1
Overnight Matching Logic
Ryan Mahoney edited this page Feb 7, 2018
·
1 revision
A user can specify a start time that is higher than the end time, for example:
Weekday Start Subscription: 11pm (23:00:00)
Weekday End Subscription: 1am (01:00:00)
For the purposes of matching, the times associated with a subscription and an alert are both converted into the format timeframe_map
which looks like:
%{
monday: %{start: 82800, end: 86399},
tuesday: %{start: 82800, end: 3600},
wednesday: %{start: 82800, end: 3600},
thursday: %{start: 82800, end: 3600},
friday: %{start: 82800, end: 3600},
saturday: %{start: 0, end: 3600}
}
When this occurs, this logic will:
- set the first day as beginning from the provided start time and ending at the last second of the day
- set the remaining days as the seconds starting with the provided start and end times
- add an extra day that starts from the first second of the day and ends with the provided end time
The logic in the time_frame_comparison.ex
is able to interpret days that have ends that are less than their beginnings and accurately match these subscriptions to alerts.