feat(alarms): collect VALARM trigger offsets from iCalendar events
- Add `triggers` field to `Remind.rem` type to store alarm trigger offsets as `Timedesc.Span.t list` - Implement `get_triggers` in `Utils` to extract duration-based triggers from audio/display alarms, ignoring email and NONE alarms - Add `collect_triggers` collector that populates the triggers field and logs them to stderr for debugging - Register `collect_triggers` in the collector pipeline - Remove leftover debug log for processed filenames in `main.ml` - Remove stale commented-out RRULE dataset and type documentation from `simple_recurrence`
This commit is contained in:
22
bin/utils.ml
22
bin/utils.ml
@@ -160,6 +160,28 @@ let get_exdates ev =
|
||||
|
||||
List.map (fun d -> `Date d) dates @ List.map (fun dt -> `Datetime dt) datetimes
|
||||
|
||||
let get_triggers ev : Timedesc.Span.t list =
|
||||
let alarms = ev.Icalendar.alarms in
|
||||
let triggers =
|
||||
ListLabels.fold_left ~init:[] alarms ~f:(fun acc alarm ->
|
||||
let trigger =
|
||||
match alarm with
|
||||
| `Audio a -> Some a.Icalendar.trigger (* we keep audio triggers *)
|
||||
| `Display d -> Some d.Icalendar.trigger (* we keep display triggers *)
|
||||
| `Email _ -> None (* we ignore email triggers *)
|
||||
| `None _ -> None (* we ignore VAL=NONE triggers *)
|
||||
in
|
||||
match trigger with
|
||||
| Some trigger -> begin
|
||||
let _, trigger_duration_or_datetime = trigger in
|
||||
match trigger_duration_or_datetime with
|
||||
| `Duration dur -> Timedesc.Utils.span_of_ptime_span dur :: acc
|
||||
| `Datetime _ -> acc
|
||||
end
|
||||
| None -> acc)
|
||||
in
|
||||
triggers
|
||||
|
||||
let get_rdates ev =
|
||||
let uid = get_uid ev in
|
||||
let event_props = ev.props in
|
||||
|
||||
Reference in New Issue
Block a user