diff --git a/cio/src/repos.rs b/cio/src/repos.rs index a43c236b8..a1bc7a4f2 100644 --- a/cio/src/repos.rs +++ b/cio/src/repos.rs @@ -285,9 +285,9 @@ impl NewRepo { has_pages: r.has_pages, has_downloads: r.has_downloads, archived: r.archived, - pushed_at: r.pushed_at.unwrap(), - created_at: r.created_at.unwrap(), - updated_at: r.updated_at.unwrap(), + pushed_at: r.pushed_at.unwrap_or_else(Utc::now), + created_at: r.created_at.unwrap_or_else(Utc::now), + updated_at: r.updated_at.unwrap_or_else(Utc::now), cio_company_id, } } @@ -357,9 +357,9 @@ impl NewRepo { has_pages: r.has_pages, has_downloads: r.has_downloads, archived: r.archived, - pushed_at: r.pushed_at.unwrap(), - created_at: r.created_at.unwrap(), - updated_at: r.updated_at.unwrap(), + pushed_at: r.pushed_at.unwrap_or_else(Utc::now), + created_at: r.created_at.unwrap_or_else(Utc::now), + updated_at: r.updated_at.unwrap_or_else(Utc::now), cio_company_id, } } diff --git a/webhooky/src/main.rs b/webhooky/src/main.rs index 0f49d3933..86ca43a69 100644 --- a/webhooky/src/main.rs +++ b/webhooky/src/main.rs @@ -309,22 +309,21 @@ async fn run_cmd(opts: crate::core::Opts, logger: slog::Logger) -> Result<()> { .into_iter() .map(|company| { tokio::spawn(enclose! { (db) async move { - tokio::join!( - cio_api::repos::sync_all_repo_settings(&db, &company), - cio_api::repos::refresh_db_github_repos(&db, &company), - ) + cio_api::repos::refresh_db_github_repos(&db, &company).await?; + cio_api::repos::sync_all_repo_settings(&db, &company).await?; + + Ok(()) }}) }) .collect(); - let mut results: Vec<(Result<()>, Result<()>)> = Default::default(); + let mut results: Vec> = Default::default(); for task in tasks { results.push(task.await?); } - for (refresh_result, cleanup_result) in results { - refresh_result?; - cleanup_result?; + for result in results { + result? } } crate::core::SubCommand::SyncRFDs(_) => { diff --git a/webhooky/src/repos.rs b/webhooky/src/repos.rs index d8a35de04..fdc0752df 100644 --- a/webhooky/src/repos.rs +++ b/webhooky/src/repos.rs @@ -2,22 +2,21 @@ use std::{fmt, str::FromStr}; /// GitHub repos. -#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] +#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] pub enum Repo { - /// (Special repo.) Any repo. - Wildcard, - Configs, RFD, + /// Any non-predefined repo + Other(String), } impl Repo { - /// Returns a static string for the repo name. - pub fn name(self) -> &'static str { + /// Returns a string for the repo name. + pub fn name(&self) -> &str { match self { - Repo::Wildcard => "*", Repo::Configs => "configs", Repo::RFD => "rfd", + Repo::Other(repo_name) => repo_name.as_str(), } } } @@ -27,12 +26,11 @@ impl FromStr for Repo { fn from_str(s: &str) -> Result { match s { - "*" => Ok(Repo::Wildcard), "configs" => Ok(Repo::Configs), "rfd" => Ok(Repo::RFD), _ => { println!("invalid GitHub repo: `{}`", s); - Ok(Repo::Wildcard) + Ok(Repo::Other(s.to_string())) } } }