treewide: format with nightly rustfmt; auto-fix Clippy lints
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I15d9215ab506b37954468d99746098326a6a6964
This commit is contained in:
parent
10a118bd50
commit
73919f2f9e
30 changed files with 144 additions and 151 deletions
|
|
@ -45,7 +45,7 @@ pub async fn list_for_build(
|
|||
}
|
||||
|
||||
/// Batch check if all dependency builds are completed for multiple builds at
|
||||
/// once. Returns a map from build_id to whether all deps are completed.
|
||||
/// once. Returns a map from `build_id` to whether all deps are completed.
|
||||
pub async fn check_deps_for_builds(
|
||||
pool: &PgPool,
|
||||
build_ids: &[Uuid],
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ pub async fn reset_orphaned(
|
|||
Ok(result.rows_affected())
|
||||
}
|
||||
|
||||
/// List builds with optional evaluation_id, status, system, and job_name
|
||||
/// List builds with optional `evaluation_id`, status, system, and `job_name`
|
||||
/// filters, with pagination.
|
||||
pub async fn list_filtered(
|
||||
pool: &PgPool,
|
||||
|
|
@ -305,7 +305,7 @@ pub async fn mark_signed(pool: &PgPool, id: Uuid) -> Result<()> {
|
|||
}
|
||||
|
||||
/// Batch-fetch completed builds by derivation paths.
|
||||
/// Returns a map from drv_path to Build for deduplication.
|
||||
/// Returns a map from `drv_path` to Build for deduplication.
|
||||
pub async fn get_completed_by_drv_paths(
|
||||
pool: &PgPool,
|
||||
drv_paths: &[String],
|
||||
|
|
@ -330,7 +330,7 @@ pub async fn get_completed_by_drv_paths(
|
|||
)
|
||||
}
|
||||
|
||||
/// Set the builder_id for a build.
|
||||
/// Set the `builder_id` for a build.
|
||||
pub async fn set_builder(
|
||||
pool: &PgPool,
|
||||
id: Uuid,
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ pub async fn list_for_jobset(
|
|||
.map_err(CiError::Database)
|
||||
}
|
||||
|
||||
/// List evaluations with optional jobset_id and status filters, with
|
||||
/// List evaluations with optional `jobset_id` and status filters, with
|
||||
/// pagination.
|
||||
pub async fn list_filtered(
|
||||
pool: &PgPool,
|
||||
|
|
@ -145,7 +145,7 @@ pub async fn set_inputs_hash(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Check if an evaluation with the same inputs_hash already exists for this
|
||||
/// Check if an evaluation with the same `inputs_hash` already exists for this
|
||||
/// jobset.
|
||||
pub async fn get_by_inputs_hash(
|
||||
pool: &PgPool,
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ pub async fn get(pool: &PgPool, id: Uuid) -> Result<ProjectMember> {
|
|||
.map_err(|e| {
|
||||
match e {
|
||||
sqlx::Error::RowNotFound => {
|
||||
CiError::NotFound(format!("Project member {} not found", id))
|
||||
CiError::NotFound(format!("Project member {id} not found"))
|
||||
},
|
||||
_ => CiError::Database(e),
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ pub async fn update(
|
|||
.map_err(|e| {
|
||||
match e {
|
||||
sqlx::Error::RowNotFound => {
|
||||
CiError::NotFound(format!("Project member {} not found", id))
|
||||
CiError::NotFound(format!("Project member {id} not found"))
|
||||
},
|
||||
_ => CiError::Database(e),
|
||||
}
|
||||
|
|
@ -141,8 +141,7 @@ pub async fn delete(pool: &PgPool, id: Uuid) -> Result<()> {
|
|||
.await?;
|
||||
if result.rows_affected() == 0 {
|
||||
return Err(CiError::NotFound(format!(
|
||||
"Project member {} not found",
|
||||
id
|
||||
"Project member {id} not found"
|
||||
)));
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use crate::{
|
|||
};
|
||||
|
||||
/// Search entity types
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum SearchEntity {
|
||||
Projects,
|
||||
Jobsets,
|
||||
|
|
@ -18,14 +18,14 @@ pub enum SearchEntity {
|
|||
}
|
||||
|
||||
/// Sort order for search results
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum SortOrder {
|
||||
Asc,
|
||||
Desc,
|
||||
}
|
||||
|
||||
/// Sort field for builds
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum BuildSortField {
|
||||
CreatedAt,
|
||||
JobName,
|
||||
|
|
@ -34,7 +34,7 @@ pub enum BuildSortField {
|
|||
}
|
||||
|
||||
/// Sort field for projects
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ProjectSortField {
|
||||
Name,
|
||||
CreatedAt,
|
||||
|
|
@ -42,7 +42,7 @@ pub enum ProjectSortField {
|
|||
}
|
||||
|
||||
/// Build status filter
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum BuildStatusFilter {
|
||||
Pending,
|
||||
Running,
|
||||
|
|
@ -492,7 +492,7 @@ pub async fn quick_search(
|
|||
query: &str,
|
||||
limit: i64,
|
||||
) -> Result<(Vec<Project>, Vec<Build>)> {
|
||||
let pattern = format!("%{}%", query);
|
||||
let pattern = format!("%{query}%");
|
||||
|
||||
let projects = sqlx::query_as::<_, Project>(
|
||||
"SELECT * FROM projects WHERE name ILIKE $1 OR description ILIKE $1 ORDER \
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ pub async fn get(pool: &PgPool, id: Uuid) -> Result<StarredJob> {
|
|||
.map_err(|e| {
|
||||
match e {
|
||||
sqlx::Error::RowNotFound => {
|
||||
CiError::NotFound(format!("Starred job {} not found", id))
|
||||
CiError::NotFound(format!("Starred job {id} not found"))
|
||||
},
|
||||
_ => CiError::Database(e),
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ pub async fn delete(pool: &PgPool, id: Uuid) -> Result<()> {
|
|||
.execute(pool)
|
||||
.await?;
|
||||
if result.rows_affected() == 0 {
|
||||
return Err(CiError::NotFound(format!("Starred job {} not found", id)));
|
||||
return Err(CiError::NotFound(format!("Starred job {id} not found")));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ pub fn hash_password(password: &str) -> Result<String> {
|
|||
argon2
|
||||
.hash_password(password.as_bytes(), &salt)
|
||||
.map(|h| h.to_string())
|
||||
.map_err(|e| CiError::Internal(format!("Password hashing failed: {}", e)))
|
||||
.map_err(|e| CiError::Internal(format!("Password hashing failed: {e}")))
|
||||
}
|
||||
|
||||
/// Verify a password against a hash
|
||||
|
|
@ -37,7 +37,7 @@ pub fn verify_password(password: &str, hash: &str) -> Result<bool> {
|
|||
use argon2::{Argon2, PasswordHash, PasswordVerifier};
|
||||
|
||||
let parsed_hash = PasswordHash::new(hash)
|
||||
.map_err(|e| CiError::Internal(format!("Invalid password hash: {}", e)))?;
|
||||
.map_err(|e| CiError::Internal(format!("Invalid password hash: {e}")))?;
|
||||
let argon2 = Argon2::default();
|
||||
Ok(
|
||||
argon2
|
||||
|
|
@ -134,7 +134,7 @@ pub async fn get(pool: &PgPool, id: Uuid) -> Result<User> {
|
|||
.map_err(|e| {
|
||||
match e {
|
||||
sqlx::Error::RowNotFound => {
|
||||
CiError::NotFound(format!("User {} not found", id))
|
||||
CiError::NotFound(format!("User {id} not found"))
|
||||
},
|
||||
_ => CiError::Database(e),
|
||||
}
|
||||
|
|
@ -321,7 +321,7 @@ pub async fn delete(pool: &PgPool, id: Uuid) -> Result<()> {
|
|||
.execute(pool)
|
||||
.await?;
|
||||
if result.rows_affected() == 0 {
|
||||
return Err(CiError::NotFound(format!("User {} not found", id)));
|
||||
return Err(CiError::NotFound(format!("User {id} not found")));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -335,7 +335,7 @@ pub async fn upsert_oauth_user(
|
|||
oauth_provider_id: &str,
|
||||
) -> Result<User> {
|
||||
// Use provider ID in username to avoid collisions
|
||||
let unique_username = format!("{}_{}", username, oauth_provider_id);
|
||||
let unique_username = format!("{username}_{oauth_provider_id}");
|
||||
|
||||
// Check if user exists by OAuth provider ID pattern
|
||||
let existing =
|
||||
|
|
@ -381,7 +381,7 @@ pub async fn upsert_oauth_user(
|
|||
VALUES ($1, $2, $3, NULL, 'read-only') RETURNING *",
|
||||
)
|
||||
.bind(&unique_username)
|
||||
.bind(email.unwrap_or(&format!("{}@oauth.local", unique_username)))
|
||||
.bind(email.unwrap_or(&format!("{unique_username}@oauth.local")))
|
||||
.bind(user_type_str)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
|
|
@ -395,7 +395,7 @@ pub async fn upsert_oauth_user(
|
|||
})
|
||||
}
|
||||
|
||||
/// Create a new session for a user. Returns (session_token, session_id).
|
||||
/// Create a new session for a user. Returns (`session_token`, `session_id`).
|
||||
pub async fn create_session(
|
||||
pool: &PgPool,
|
||||
user_id: Uuid,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue