From 40e57b68eb868a1b24972da40f0a0d9704475a96 Mon Sep 17 00:00:00 2001 From: orbifx Date: Thu, 23 Sep 2021 19:31:50 +0100 Subject: [PATCH] In progress: improvement of message presentation --- http/http.ml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/http/http.ml b/http/http.ml index 927934f..662ceda 100644 --- a/http/http.ml +++ b/http/http.ml @@ -105,8 +105,13 @@ let pull_msgs url _authors _topics = match http_apply response url with in let s = Scanf.Scanning.from_string body in let msgs = MsgSet.empty in - let msgs = fold_msgs s msgs (fun msgs t m -> match Ptime.of_rfc3339 t with Ok (v,_,_) -> MsgSet.add (v,m) msgs | _ -> msgs) in - MsgSet.iter (fun (t,m) -> print_endline (Ptime.to_rfc3339 t ^ " @ " ^ m)) msgs + let msgs = fold_msgs s msgs + (fun msgs t m -> match Ptime.of_rfc3339 t with + | Ok (v,_,_) -> let open MsgSet in + let msgs = if cardinal msgs > 3 then remove (max_elt msgs) msgs else msgs in + add (v,m) msgs + | _ -> msgs) in + MsgSet.iter (fun (t,m) -> print_endline (m ^ "\n\t\t -- " ^ Ptime.to_rfc3339 t)) msgs let pull_fn url = match Uri.of_string url with | x when x = Uri.empty -> (fun _ _ -> ())