From 7a3cd6d029e73a28e1229ac24edb4c5bd87162b9 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sat, 3 Oct 2020 16:29:37 +0200 Subject: course: remove reference to unused fields in the original JSON feed It's cleaner to merge an actual obj with a unit instead of refering to every field in the JSON feed, and makes the schema more flexible. Signed-off-by: Alban Gruin --- src/course.ml | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/src/course.ml b/src/course.ml index aede83e..52aa062 100644 --- a/src/course.ml +++ b/src/course.ml @@ -90,35 +90,20 @@ let date = let encoding = J.(conv - (fun _ -> (None, None, "", "", (), (), ()), - ((), (), (), (), (), (), (), (), (), ())) - (fun ((start, stop, description, category, (), (), ()), - ((), (), (), (), (), (), (), (), (), ())) -> + (fun _ -> (None, None, "", ""), ()) + (fun ((start, stop, description, category), ()) -> let location, summary = location_and_summary description category in match start, stop with | Some start, Some stop -> Some (Ics.Event.make start stop summary location) | _, _ -> None) (merge_objs - (obj7 + (obj4 (req "start" @@ option date) (req "end" @@ option date) (req "description" string) - (req "eventCategory" string) - (req "id" unit) - (req "allDay" unit) - (req "backgroundColor" unit)) - (obj10 - (req "textColor" unit) - (req "department" unit) - (req "faculty" unit) - (req "sites" unit) - (req "modules" unit) - (req "registerStatus" unit) - (req "studentMark" unit) - (req "custom1" unit) - (req "custom2" unit) - (req "custom3" unit)))) + (req "eventCategory" string)) + unit)) let decode s = let toks = -- cgit v1.2.1