Radish alpha
r
rad:zwTxygwuz5LDGBq255RA2CbNGrz8
Radicle CI broker
Radicle
Git
feat: produce RSS feed of unfinished CI runs
Lars Wirzenius committed 1 year ago
commit 00ca0e8fccf23fd04697c35d044b5b89f915b49e
parent e69262d
1 file changed +22 -0
modified src/pages.rs
@@ -40,6 +40,7 @@ use crate::{

const BROKER_RSS: &str = "index.rss";
const FAILURE_RSS: &str = "failed.rss";
+
const UNFINISHED_RSS: &str = "unfinished.rss";
const CSS: &str = include_str!("radicle-ci.css");
const REFERESH_INTERVAL: &str = "300";
const UPDATE_INTERVAL: Duration = Duration::from_secs(60);
@@ -627,6 +628,22 @@ impl PageData {
        Ok(channel.build())
    }

+
    fn unfinished_as_rss(&self) -> Result<Channel, PageError> {
+
        let mut channel = ChannelBuilder::default();
+
        channel
+
            .title("Radicle CI broker run information")
+
            .description("All CI runs known to this instance of the Radicle CI broker.")
+
            .link("FIXME:link");
+
        for (_alias, repo_id) in self.repos() {
+
            for run in self.runs(repo_id) {
+
                if run.state() == RunState::Triggered || run.state() == RunState::Running {
+
                    channel.item(Self::rss_item_from_run(run)?);
+
                }
+
            }
+
        }
+
        Ok(channel.build())
+
    }
+

    fn rss_item_from_run(run: &Run) -> Result<Item, PageError> {
        let mut guid = Guid::default();
        guid.set_value(run.broker_run_id().to_string());
@@ -857,6 +874,11 @@ impl StatusPage {
            let channel = data.failed_as_rss()?;
            let rss = channel.to_string();
            Self::write_file(&filename, &rss)?;
+

+
            let filename = dirname.join(UNFINISHED_RSS);
+
            let channel = data.unfinished_as_rss()?;
+
            let rss = channel.to_string();
+
            Self::write_file(&filename, &rss)?;
        }
        Ok(())
    }