From ef8fe3631b20d969effa2e1e0737536deb6139f6 Mon Sep 17 00:00:00 2001 From: sabine <6594573+sabine@users.noreply.github.com> Date: Sat, 21 Dec 2024 14:21:39 +0100 Subject: [PATCH] fix: have at least one item in every RSS feed even if older than cutoff time --- tool/ood-gen/lib/news.ml | 2 +- tool/ood-gen/lib/rss.ml | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tool/ood-gen/lib/news.ml b/tool/ood-gen/lib/news.ml index 9d4835e870..068de981a3 100644 --- a/tool/ood-gen/lib/news.ml +++ b/tool/ood-gen/lib/news.ml @@ -54,7 +54,7 @@ module RssFeed = struct let create_feed () = let open Rss in all () - |> create_entries ~create_entry ~days:9000 (* FIXME *) + |> create_entries ~create_entry ~days:90 |> entries_to_feed ~id:"news.xml" ~title:"OCaml News @ OCaml.org" |> feed_to_string end diff --git a/tool/ood-gen/lib/rss.ml b/tool/ood-gen/lib/rss.ml index 15eced58c3..80783f545c 100644 --- a/tool/ood-gen/lib/rss.ml +++ b/tool/ood-gen/lib/rss.ml @@ -7,8 +7,12 @@ let create_entries ~create_entry ?days u = in Option.fold ~none:Option.some ~some days in - let entries = u |> List.filter_map (fun x -> x |> create_entry |> is_fresh) in - entries + let entries = + List.tl u |> List.map create_entry |> List.sort Syndic.Atom.descending + in + match List.filter_map is_fresh entries with + | [] -> [ List.hd entries ] + | xs -> xs let entries_to_feed ~id ~title (entries : Syndic.Atom.entry list) = let id = Uri.of_string ("https://ocaml.org/" ^ id) in