chore: collapse if statements; autofix Clippy warnings

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I2765a6864b5435d803472b0fba313d7e6a6a6964
This commit is contained in:
raf 2026-02-28 23:33:16 +03:00
commit eb8b231340
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
4 changed files with 7 additions and 6 deletions

View file

@ -28,6 +28,7 @@ pub struct RateLimitState {
pub reset_at: u64,
}
#[must_use]
pub fn extract_rate_limit_from_headers(
headers: &reqwest::header::HeaderMap,
) -> Option<RateLimitState> {
@ -37,6 +38,7 @@ pub fn extract_rate_limit_from_headers(
Some(RateLimitState { limit, remaining, reset_at })
}
#[must_use]
pub fn calculate_delay(state: &RateLimitState, now: u64) -> u64 {
let seconds_until_reset = state.reset_at.saturating_sub(now).max(1);
let consumed = state.limit.saturating_sub(state.remaining);

View file

@ -28,13 +28,12 @@ pub async fn create(
.fetch_one(pool)
.await
.map_err(|e| {
if let sqlx::Error::Database(db_err) = &e {
if db_err.is_unique_violation() {
if let sqlx::Error::Database(db_err) = &e
&& db_err.is_unique_violation() {
return CiError::Conflict(format!(
"Build output with name '{name}' already exists for build {build}"
));
}
}
CiError::Database(e)
})
}