chore: collapse if statements; autofix Clippy warnings
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I2765a6864b5435d803472b0fba313d7e6a6a6964
This commit is contained in:
parent
92844d302e
commit
eb8b231340
4 changed files with 7 additions and 6 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue