Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
fix: adapt src/broker.rs to new database abstraction
Lars Wirzenius committed 1 year ago
commit 6e5c0d02903409df8fb744b9fd78722f729fdd05
parent 1386c94189c60ddb3037e5946c59e2c5f058f3e2
1 file changed +8 -3
modified src/broker.rs
@@ -24,7 +24,6 @@ use crate::{
/// The broker gets repository change events from the local Radicle
/// node, and executes the appropriate adapter to run CI on the
/// repository.
-
#[derive(Debug)]
pub struct Broker {
    default_adapter: Option<Adapter>,
    adapters: HashMap<RepoId, Adapter>,
@@ -44,7 +43,13 @@ impl Broker {

    #[allow(clippy::result_large_err)]
    pub fn all_runs(&mut self) -> Result<Vec<Run>, BrokerError> {
-
        self.db.all_runs().map_err(BrokerError::Db)
+
        let mut runs = vec![];
+
        for run_id in self.db.list_runs().map_err(BrokerError::Db)? {
+
            if let Some(run) = self.db.get_run(&run_id).map_err(BrokerError::Db)? {
+
                runs.push(run);
+
            }
+
        }
+
        Ok(runs)
    }

    pub fn set_default_adapter(&mut self, adapter: &Adapter) {
@@ -122,8 +127,8 @@ impl Broker {
                }
            }
        };
-
        self.db.push_run(&run)?;
        debug!("Finish CI run: {run:#?}");
+
        self.db.push_run(run.clone())?;

        Ok(run)
    }