From d489f3743cca9e6fb3dddbf10bbcb1e188b09f0b Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sun, 19 Sep 2021 12:20:04 +0200 Subject: server, ics: add a facility to filter courses by groups When fetching courses based on their module ID, it is interesting to exclude coruses that do not apply to some groups. This adds the functionnality to apply that filtering, with the Ics.filter_groups function. It also becomes possible to get ICS for modules. URLs and generators are changed accordingly. Signed-off-by: Alban Gruin --- src/ics.ml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/ics.ml') diff --git a/src/ics.ml b/src/ics.ml index f1b6cc5..888e9e8 100644 --- a/src/ics.ml +++ b/src/ics.ml @@ -57,12 +57,19 @@ module Event = struct "END:VEVENT\n"] |> List.map ics_split_line |> String.concat "\n" + + let has_groups groups event = + List.fold_left (fun found group -> + found || List.exists ((=) group) groups) false event.groups end type t = Event.t list let make events = events +let filter_groups groups = + List.filter (Event.has_groups groups) + let gen_vtimezone tz = if tz <> "" then ["BEGIN:VTIMEZONE"; -- cgit v1.2.1