Radish alpha
r
rad:zwTxygwuz5LDGBq255RA2CbNGrz8
Radicle CI broker
Radicle
Git
feat: RSS feeds now only contain up to ten entries
Merged liw opened 1 year ago

Very long RSS feeds can cause problems for some readers. Apparently they forget they’ve already seen very old entries and show them as new. To work around this, only include the ten newest CI runs.

Signed-off-by: Lars Wirzenius liw@liw.fi

1 file changed +8 -1 746445cb 4f981273
modified src/pages.rs
@@ -38,6 +38,7 @@ use crate::{
    util::{parse_timestamp, rfc822_timestamp},
};

+
const MAX_RSS_ENTRIES: usize = 10;
const BROKER_RSS: &str = "index.rss";
const FAILURE_RSS: &str = "failed.rss";
const UNFINISHED_RSS: &str = "unfinished.rss";
@@ -604,11 +605,17 @@ impl PageData {
            .title("Radicle CI broker run information")
            .description("All CI runs known to this instance of the Radicle CI broker.")
            .link("FIXME:link");
+
        let mut items = vec![];
        for (_alias, repo_id) in self.repos() {
            for run in self.runs(repo_id) {
-
                channel.item(Self::rss_item_from_run(run)?);
+
                items.push(Self::rss_item_from_run(run)?);
            }
        }
+
        items.sort_by_key(|item| item.pub_date().map(|s| s.to_string()));
+
        items.reverse();
+
        for item in items.iter().take(MAX_RSS_ENTRIES).cloned() {
+
            channel.item(item);
+
        }
        Ok(channel.build())
    }