From 33e6cd8a3aed535ffbcd0fac94df0d22308a1231 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Fri, 12 Apr 2024 16:23:04 +0200 Subject: [PATCH] feat: make sure to run a distinct first Signed-off-by: kjuulh --- Cargo.lock | 1 + crates/contractor/Cargo.toml | 1 + crates/contractor/src/services/gitea.rs | 3 +-- crates/contractor/src/services/reconciler.rs | 4 +++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8e2db86..04cc68a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -319,6 +319,7 @@ dependencies = [ "clap", "dotenv", "futures", + "itertools", "reqwest", "serde", "sqlx", diff --git a/crates/contractor/Cargo.toml b/crates/contractor/Cargo.toml index eeec02c..6bc08c7 100644 --- a/crates/contractor/Cargo.toml +++ b/crates/contractor/Cargo.toml @@ -18,3 +18,4 @@ uuid = { version = "1.7.0", features = ["v4"] } tower-http = { version = "0.5.2", features = ["cors", "trace"] } futures = "0.3.30" reqwest = {version = "0.12.3", default-features = false, features = ["json", "rustls-tls"]} +itertools = "0.12.1" diff --git a/crates/contractor/src/services/gitea.rs b/crates/contractor/src/services/gitea.rs index 2a164da..25bac0b 100644 --- a/crates/contractor/src/services/gitea.rs +++ b/crates/contractor/src/services/gitea.rs @@ -17,7 +17,7 @@ impl Deref for GiteaClient { } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct Repository { pub owner: String, pub name: String, @@ -142,6 +142,5 @@ mod extensions; pub mod traits; use anyhow::Context; -use axum::http::HeaderMap; pub use extensions::*; use serde::Deserialize; diff --git a/crates/contractor/src/services/reconciler.rs b/crates/contractor/src/services/reconciler.rs index 458721c..63d8ab1 100644 --- a/crates/contractor/src/services/reconciler.rs +++ b/crates/contractor/src/services/reconciler.rs @@ -1,3 +1,5 @@ +use itertools::Itertools; + use crate::SharedState; use super::gitea::{GiteaClient, GiteaClientState, Repository}; @@ -43,7 +45,7 @@ impl Reconciler { } } - Ok(repos) + Ok(repos.into_iter().unique().collect()) } }