Skip to content

Commit

Permalink
fix: have at least one item in every RSS feed even if older than cuto…
Browse files Browse the repository at this point in the history
…ff time (#2890)
  • Loading branch information
sabine authored Dec 21, 2024
1 parent ccf5180 commit dc6da52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tool/ood-gen/lib/news.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 6 additions & 2 deletions tool/ood-gen/lib/rss.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dc6da52

Please sign in to comment.