treewide: format with nightly rustfmt; auto-fix Clippy lints
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: If4fd0511087dbaa65afc56a34d7c2f166a6a6964
This commit is contained in:
parent
fe45fff3f3
commit
3a03cf7b3e
26 changed files with 222 additions and 161 deletions
|
|
@ -96,8 +96,8 @@ pub async fn upsert(
|
|||
) -> Result<Channel> {
|
||||
sqlx::query_as::<_, Channel>(
|
||||
"INSERT INTO channels (project_id, name, jobset_id) VALUES ($1, $2, $3) \
|
||||
ON CONFLICT (project_id, name) DO UPDATE SET jobset_id = EXCLUDED.jobset_id \
|
||||
RETURNING *",
|
||||
ON CONFLICT (project_id, name) DO UPDATE SET jobset_id = \
|
||||
EXCLUDED.jobset_id RETURNING *",
|
||||
)
|
||||
.bind(project_id)
|
||||
.bind(name)
|
||||
|
|
@ -119,12 +119,14 @@ pub async fn sync_for_project(
|
|||
let names: Vec<&str> = channels.iter().map(|c| c.name.as_str()).collect();
|
||||
|
||||
// Delete channels not in declarative config
|
||||
sqlx::query("DELETE FROM channels WHERE project_id = $1 AND name != ALL($2::text[])")
|
||||
.bind(project_id)
|
||||
.bind(&names)
|
||||
.execute(pool)
|
||||
.await
|
||||
.map_err(CiError::Database)?;
|
||||
sqlx::query(
|
||||
"DELETE FROM channels WHERE project_id = $1 AND name != ALL($2::text[])",
|
||||
)
|
||||
.bind(project_id)
|
||||
.bind(&names)
|
||||
.execute(pool)
|
||||
.await
|
||||
.map_err(CiError::Database)?;
|
||||
|
||||
// Upsert each channel
|
||||
for channel in channels {
|
||||
|
|
|
|||
|
|
@ -73,12 +73,9 @@ pub async fn upsert(
|
|||
) -> Result<JobsetInput> {
|
||||
sqlx::query_as::<_, JobsetInput>(
|
||||
"INSERT INTO jobset_inputs (jobset_id, name, input_type, value, revision) \
|
||||
VALUES ($1, $2, $3, $4, $5) \
|
||||
ON CONFLICT (jobset_id, name) DO UPDATE SET \
|
||||
input_type = EXCLUDED.input_type, \
|
||||
value = EXCLUDED.value, \
|
||||
revision = EXCLUDED.revision \
|
||||
RETURNING *",
|
||||
VALUES ($1, $2, $3, $4, $5) ON CONFLICT (jobset_id, name) DO UPDATE SET \
|
||||
input_type = EXCLUDED.input_type, value = EXCLUDED.value, revision = \
|
||||
EXCLUDED.revision RETURNING *",
|
||||
)
|
||||
.bind(jobset_id)
|
||||
.bind(name)
|
||||
|
|
@ -102,7 +99,8 @@ pub async fn sync_for_jobset(
|
|||
|
||||
// Delete inputs not in declarative config
|
||||
sqlx::query(
|
||||
"DELETE FROM jobset_inputs WHERE jobset_id = $1 AND name != ALL($2::text[])",
|
||||
"DELETE FROM jobset_inputs WHERE jobset_id = $1 AND name != \
|
||||
ALL($2::text[])",
|
||||
)
|
||||
.bind(jobset_id)
|
||||
.bind(&names)
|
||||
|
|
|
|||
|
|
@ -231,8 +231,8 @@ pub async fn has_running_builds(
|
|||
}
|
||||
|
||||
/// List jobsets that are due for evaluation based on their `check_interval`.
|
||||
/// Returns jobsets where `last_checked_at` is NULL or older than `check_interval`
|
||||
/// seconds.
|
||||
/// Returns jobsets where `last_checked_at` is NULL or older than
|
||||
/// `check_interval` seconds.
|
||||
pub async fn list_due_for_eval(
|
||||
pool: &PgPool,
|
||||
limit: i64,
|
||||
|
|
|
|||
|
|
@ -70,9 +70,9 @@ pub async fn upsert(
|
|||
) -> Result<NotificationConfig> {
|
||||
sqlx::query_as::<_, NotificationConfig>(
|
||||
"INSERT INTO notification_configs (project_id, notification_type, config, \
|
||||
enabled) VALUES ($1, $2, $3, $4) ON CONFLICT (project_id, notification_type) \
|
||||
DO UPDATE SET config = EXCLUDED.config, enabled = EXCLUDED.enabled \
|
||||
RETURNING *",
|
||||
enabled) VALUES ($1, $2, $3, $4) ON CONFLICT (project_id, \
|
||||
notification_type) DO UPDATE SET config = EXCLUDED.config, enabled = \
|
||||
EXCLUDED.enabled RETURNING *",
|
||||
)
|
||||
.bind(project_id)
|
||||
.bind(notification_type)
|
||||
|
|
|
|||
|
|
@ -141,9 +141,7 @@ pub async fn delete(pool: &PgPool, id: Uuid) -> Result<()> {
|
|||
.execute(pool)
|
||||
.await?;
|
||||
if result.rows_affected() == 0 {
|
||||
return Err(CiError::NotFound(format!(
|
||||
"Project member {id} not found"
|
||||
)));
|
||||
return Err(CiError::NotFound(format!("Project member {id} not found")));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -199,8 +197,8 @@ pub async fn upsert(
|
|||
.map_err(|e| CiError::Validation(e.to_string()))?;
|
||||
|
||||
sqlx::query_as::<_, ProjectMember>(
|
||||
"INSERT INTO project_members (project_id, user_id, role) VALUES ($1, $2, $3) \
|
||||
ON CONFLICT (project_id, user_id) DO UPDATE SET role = EXCLUDED.role \
|
||||
"INSERT INTO project_members (project_id, user_id, role) VALUES ($1, $2, \
|
||||
$3) ON CONFLICT (project_id, user_id) DO UPDATE SET role = EXCLUDED.role \
|
||||
RETURNING *",
|
||||
)
|
||||
.bind(project_id)
|
||||
|
|
|
|||
|
|
@ -152,9 +152,9 @@ pub async fn upsert(
|
|||
sqlx::query_as::<_, RemoteBuilder>(
|
||||
"INSERT INTO remote_builders (name, ssh_uri, systems, max_jobs, \
|
||||
speed_factor, supported_features, mandatory_features, enabled, \
|
||||
public_host_key, ssh_key_file) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, \
|
||||
$10) ON CONFLICT (name) DO UPDATE SET ssh_uri = EXCLUDED.ssh_uri, systems = \
|
||||
EXCLUDED.systems, max_jobs = EXCLUDED.max_jobs, speed_factor = \
|
||||
public_host_key, ssh_key_file) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, \
|
||||
$9, $10) ON CONFLICT (name) DO UPDATE SET ssh_uri = EXCLUDED.ssh_uri, \
|
||||
systems = EXCLUDED.systems, max_jobs = EXCLUDED.max_jobs, speed_factor = \
|
||||
EXCLUDED.speed_factor, supported_features = EXCLUDED.supported_features, \
|
||||
mandatory_features = EXCLUDED.mandatory_features, enabled = \
|
||||
EXCLUDED.enabled, public_host_key = COALESCE(EXCLUDED.public_host_key, \
|
||||
|
|
|
|||
|
|
@ -364,7 +364,8 @@ async fn search_evaluations(
|
|||
}
|
||||
}
|
||||
|
||||
// Get count - simple count (full filter support would require building query differently)
|
||||
// Get count - simple count (full filter support would require building query
|
||||
// differently)
|
||||
let (total,): (i64,) = sqlx::query_as("SELECT COUNT(*) FROM evaluations")
|
||||
.fetch_one(pool)
|
||||
.await?;
|
||||
|
|
|
|||
|
|
@ -94,10 +94,10 @@ pub async fn upsert(
|
|||
enabled: bool,
|
||||
) -> Result<WebhookConfig> {
|
||||
sqlx::query_as::<_, WebhookConfig>(
|
||||
"INSERT INTO webhook_configs (project_id, forge_type, secret_hash, enabled) \
|
||||
VALUES ($1, $2, $3, $4) ON CONFLICT (project_id, forge_type) DO UPDATE SET \
|
||||
secret_hash = COALESCE(EXCLUDED.secret_hash, webhook_configs.secret_hash), \
|
||||
enabled = EXCLUDED.enabled RETURNING *",
|
||||
"INSERT INTO webhook_configs (project_id, forge_type, secret_hash, \
|
||||
enabled) VALUES ($1, $2, $3, $4) ON CONFLICT (project_id, forge_type) DO \
|
||||
UPDATE SET secret_hash = COALESCE(EXCLUDED.secret_hash, \
|
||||
webhook_configs.secret_hash), enabled = EXCLUDED.enabled RETURNING *",
|
||||
)
|
||||
.bind(project_id)
|
||||
.bind(forge_type)
|
||||
|
|
@ -117,7 +117,8 @@ pub async fn sync_for_project(
|
|||
resolve_secret: impl Fn(&DeclarativeWebhook) -> Option<String>,
|
||||
) -> Result<()> {
|
||||
// Get forge types from declarative config
|
||||
let types: Vec<&str> = webhooks.iter().map(|w| w.forge_type.as_str()).collect();
|
||||
let types: Vec<&str> =
|
||||
webhooks.iter().map(|w| w.forge_type.as_str()).collect();
|
||||
|
||||
// Delete webhook configs not in declarative config
|
||||
sqlx::query(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue