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
|
|
@ -109,6 +109,7 @@ similar_names = "allow"
|
||||||
single_call_fn = "allow"
|
single_call_fn = "allow"
|
||||||
std_instead_of_core = "allow"
|
std_instead_of_core = "allow"
|
||||||
too_long_first_doc_paragraph = "allow"
|
too_long_first_doc_paragraph = "allow"
|
||||||
|
too_many_arguments = "allow" # I don't care
|
||||||
too_many_lines = "allow"
|
too_many_lines = "allow"
|
||||||
undocumented_unsafe_blocks = "warn"
|
undocumented_unsafe_blocks = "warn"
|
||||||
unnecessary_safety_comment = "warn"
|
unnecessary_safety_comment = "warn"
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ pub struct RateLimitState {
|
||||||
pub reset_at: u64,
|
pub reset_at: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn extract_rate_limit_from_headers(
|
pub fn extract_rate_limit_from_headers(
|
||||||
headers: &reqwest::header::HeaderMap,
|
headers: &reqwest::header::HeaderMap,
|
||||||
) -> Option<RateLimitState> {
|
) -> Option<RateLimitState> {
|
||||||
|
|
@ -37,6 +38,7 @@ pub fn extract_rate_limit_from_headers(
|
||||||
Some(RateLimitState { limit, remaining, reset_at })
|
Some(RateLimitState { limit, remaining, reset_at })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn calculate_delay(state: &RateLimitState, now: u64) -> u64 {
|
pub fn calculate_delay(state: &RateLimitState, now: u64) -> u64 {
|
||||||
let seconds_until_reset = state.reset_at.saturating_sub(now).max(1);
|
let seconds_until_reset = state.reset_at.saturating_sub(now).max(1);
|
||||||
let consumed = state.limit.saturating_sub(state.remaining);
|
let consumed = state.limit.saturating_sub(state.remaining);
|
||||||
|
|
|
||||||
|
|
@ -28,13 +28,12 @@ pub async fn create(
|
||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
if let sqlx::Error::Database(db_err) = &e {
|
if let sqlx::Error::Database(db_err) = &e
|
||||||
if db_err.is_unique_violation() {
|
&& db_err.is_unique_violation() {
|
||||||
return CiError::Conflict(format!(
|
return CiError::Conflict(format!(
|
||||||
"Build output with name '{name}' already exists for build {build}"
|
"Build output with name '{name}' already exists for build {build}"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
CiError::Database(e)
|
CiError::Database(e)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -209,8 +209,8 @@ pub async fn run(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unsupported system timeout: abort builds with no available builders
|
// Unsupported system timeout: abort builds with no available builders
|
||||||
if let Some(timeout) = unsupported_timeout {
|
if let Some(timeout) = unsupported_timeout
|
||||||
if let Some(system) = &build.system {
|
&& let Some(system) = &build.system {
|
||||||
match repo::remote_builders::find_for_system(&pool, system).await {
|
match repo::remote_builders::find_for_system(&pool, system).await {
|
||||||
Ok(builders) if builders.is_empty() => {
|
Ok(builders) if builders.is_empty() => {
|
||||||
let timeout_at = build.created_at + timeout;
|
let timeout_at = build.created_at + timeout;
|
||||||
|
|
@ -252,7 +252,6 @@ pub async fn run(
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// One-at-a-time scheduling: check if jobset allows concurrent builds
|
// One-at-a-time scheduling: check if jobset allows concurrent builds
|
||||||
// First, get the evaluation to find the jobset
|
// First, get the evaluation to find the jobset
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue