OXYGENHUB

Clippy: check reports as a struct; no needless borrow; unused test imports (lint gate correction) db72849cd22e

Author
Andy McCall @andymccall <[email protected]>
When
· 2026-09-27 19:31 UTC
Signature
✔ signed by Andy McCall
Hash
db72849cd22e82e6160e21528548f9766cf4b10867415ce1b2fe177bfa05e71f
Depends on
b64e2537d702 d23464c0ac60
Depended on by
nothing yet
In bookmarks
api-unknown-fields cancel-landed-runs clear-waiting close-proposal-140 diffusion-pin-bookmark draft-ready image-check job-waits main oh-comment-body-file proposal-list-fast run-one-job wiki-says-so
In tags
v0.1.0 v0.2.0 v0.3.0 v0.3.1 v0.4.0 v0.4.1 v0.4.2 v0.5.0 v0.5.1 v0.5.2 v0.6.0 v0.6.1 v0.7.0 v0.8.0 v0.9.0 v0.9.1 v0.9.11 v0.9.15 v0.9.16 v0.9.19 v0.9.2 v0.9.20 v0.9.21 v0.9.22 v0.9.23 v0.9.24 v0.9.3 v0.9.4 v0.9.5 v0.9.6 v0.9.7 v0.9.8 v0.9.9
Edits
6 atoms, 0 tree operations, 3 files

Browse the tree at this change

modified crates/hub/src/api/mod.rs +9 −7
…
1026 unchanged lines
1027 1027
    let ch = db::hooks::upsert_check(
1028 1028
        &app.db,
1029 1029
        row.id,
1030 -
        &body.state,
1031 -
        body.name.trim(),
1032 -
        body.status.as_str(),
1033 -
        &body.summary,
1034 -
        &body.url,
1035 -
        Some((me.id, &me.username)),
1036 -
        body.seal.as_deref().unwrap_or(""),
1030 +
        db::hooks::CheckReport {
1031 +
            state: &body.state,
1032 +
            name: body.name.trim(),
1033 +
            status: body.status.as_str(),
1034 +
            summary: &body.summary,
1035 +
            url: &body.url,
1036 +
            reporter: Some((me.id, &me.username)),
1037 +
            seal: body.seal.as_deref().unwrap_or(""),
1038 +
        },
1037 1039
    )
1038 1040
    .await?;
1039 1041
    let api = check_of(&ch);
…
14 unchanged lines
modified crates/hub/src/db/hooks.rs +14 −12
…
133 unchanged lines
134 134
    sqlx::query("UPDATE deliveries SET attempts = ?, status = ?, response = ?, delivered_ms = ?, next_ms = ? WHERE id = ?")
135 135
        .bind(attempts + 1)
136 136
        .bind(status)
137 -
        .bind(&response.chars().take(2000).collect::<String>())
137 +
        .bind(response.chars().take(2000).collect::<String>())
138 138
        .bind(delivered)
139 139
        .bind(next)
140 140
        .bind(id)
…
42 unchanged lines
183 183
}
184 184
185 185
/// Create or update a check by `(state, name)`.
186 -
pub async fn upsert_check(
187 -
    pool: &Pool,
188 -
    repo_id: i64,
189 -
    state: &str,
190 -
    name: &str,
191 -
    status: &str,
192 -
    summary: &str,
193 -
    url: &str,
194 -
    reporter: Option<(i64, &str)>,
195 -
    seal: &str,
196 -
) -> sqlx::Result<Check> {
186 +
/// A check as a reporter posts it.
187 +
pub struct CheckReport<'a> {
188 +
    pub state: &'a str,
189 +
    pub name: &'a str,
190 +
    pub status: &'a str,
191 +
    pub summary: &'a str,
192 +
    pub url: &'a str,
193 +
    pub reporter: Option<(i64, &'a str)>,
194 +
    pub seal: &'a str,
195 +
}
196 +
197 +
pub async fn upsert_check(pool: &Pool, repo_id: i64, c: CheckReport<'_>) -> sqlx::Result<Check> {
198 +
    let CheckReport { state, name, status, summary, url, reporter, seal } = c;
197 199
    let now = now_ms();
198 200
    let finished: Option<i64> = if matches!(status, "passed" | "failed" | "cancelled" | "skipped") { Some(now) } else { None };
199 201
    sqlx::query_as(
…
27 unchanged lines
modified crates/hub/tests/api.rs +0 −2
…
8 unchanged lines
9 9
use http_body_util::BodyExt;
10 10
use oxy_core::repo::Repo;
11 11
use oxygenhub::config::Config;
12 -
use oxygenhub::db;
13 -
use oxygenhub::repos::RepoName;
14 12
use oxygenhub::Shared;
15 13
use std::path::Path;
16 14
use std::sync::{Arc, Mutex};
…
302 unchanged lines