From 23a4a8e348fe20cca6d08b90fd8ae4f9aae7fdbd Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 18 Feb 2026 11:30:58 +0300 Subject: [PATCH] fc-common: format Signed-off-by: NotAShelf Change-Id: I946272ee6563f5bca0844c5a25ba08f66a6a6964 --- crates/common/src/models.rs | 30 +++++++++++------------ crates/common/src/repo/builds.rs | 6 +---- crates/common/src/repo/remote_builders.rs | 22 +++++++---------- 3 files changed, 25 insertions(+), 33 deletions(-) diff --git a/crates/common/src/models.rs b/crates/common/src/models.rs index 64968e2..742429d 100644 --- a/crates/common/src/models.rs +++ b/crates/common/src/models.rs @@ -413,21 +413,21 @@ pub struct Channel { /// Remote builder for multi-machine / multi-arch builds. #[derive(Debug, Clone, Serialize, Deserialize, FromRow)] pub struct RemoteBuilder { - pub id: Uuid, - pub name: String, - pub ssh_uri: String, - pub systems: Vec, - pub max_jobs: i32, - pub speed_factor: i32, - pub supported_features: Vec, - pub mandatory_features: Vec, - pub enabled: bool, - pub public_host_key: Option, - pub ssh_key_file: Option, - pub created_at: DateTime, - pub consecutive_failures: i32, - pub disabled_until: Option>, - pub last_failure: Option>, + pub id: Uuid, + pub name: String, + pub ssh_uri: String, + pub systems: Vec, + pub max_jobs: i32, + pub speed_factor: i32, + pub supported_features: Vec, + pub mandatory_features: Vec, + pub enabled: bool, + pub public_host_key: Option, + pub ssh_key_file: Option, + pub created_at: DateTime, + pub consecutive_failures: i32, + pub disabled_until: Option>, + pub last_failure: Option>, } /// User account for authentication and personalization diff --git a/crates/common/src/repo/builds.rs b/crates/common/src/repo/builds.rs index f826ef3..6ac0a67 100644 --- a/crates/common/src/repo/builds.rs +++ b/crates/common/src/repo/builds.rs @@ -387,11 +387,7 @@ pub async fn list_pinned_ids( } /// Set the `keep` (GC pin) flag on a build. -pub async fn set_keep( - pool: &PgPool, - id: Uuid, - keep: bool, -) -> Result { +pub async fn set_keep(pool: &PgPool, id: Uuid, keep: bool) -> Result { sqlx::query_as::<_, Build>( "UPDATE builds SET keep = $1 WHERE id = $2 RETURNING *", ) diff --git a/crates/common/src/repo/remote_builders.rs b/crates/common/src/repo/remote_builders.rs index dd3e315..6ceb147 100644 --- a/crates/common/src/repo/remote_builders.rs +++ b/crates/common/src/repo/remote_builders.rs @@ -77,8 +77,8 @@ pub async fn find_for_system( ) -> Result> { sqlx::query_as::<_, RemoteBuilder>( "SELECT * FROM remote_builders WHERE enabled = true AND $1 = ANY(systems) \ - AND (disabled_until IS NULL OR disabled_until < NOW()) \ - ORDER BY speed_factor DESC", + AND (disabled_until IS NULL OR disabled_until < NOW()) ORDER BY \ + speed_factor DESC", ) .bind(system) .fetch_all(pool) @@ -92,13 +92,11 @@ pub async fn find_for_system( /// Backoff formula (from Hydra): delta = 60 * 3^(min(failures, 4) - 1) seconds. pub async fn record_failure(pool: &PgPool, id: Uuid) -> Result { sqlx::query_as::<_, RemoteBuilder>( - "UPDATE remote_builders SET \ - consecutive_failures = LEAST(consecutive_failures + 1, 4), \ - last_failure = NOW(), \ - disabled_until = NOW() + make_interval(secs => \ - 60.0 * power(3, LEAST(consecutive_failures + 1, 4) - 1) + (random() * 30)::int \ - ) \ - WHERE id = $1 RETURNING *", + "UPDATE remote_builders SET consecutive_failures = \ + LEAST(consecutive_failures + 1, 4), last_failure = NOW(), disabled_until \ + = NOW() + make_interval(secs => 60.0 * power(3, \ + LEAST(consecutive_failures + 1, 4) - 1) + (random() * 30)::int ) WHERE \ + id = $1 RETURNING *", ) .bind(id) .fetch_optional(pool) @@ -110,10 +108,8 @@ pub async fn record_failure(pool: &PgPool, id: Uuid) -> Result { /// Resets consecutive_failures and clears disabled_until. pub async fn record_success(pool: &PgPool, id: Uuid) -> Result { sqlx::query_as::<_, RemoteBuilder>( - "UPDATE remote_builders SET \ - consecutive_failures = 0, \ - disabled_until = NULL \ - WHERE id = $1 RETURNING *", + "UPDATE remote_builders SET consecutive_failures = 0, disabled_until = \ + NULL WHERE id = $1 RETURNING *", ) .bind(id) .fetch_optional(pool)