fc-common: add advanced search functionality with filters and sorting

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ib48f9bd42eea289b9eb8b13e3bd60ed86a6a6964
This commit is contained in:
raf 2026-02-08 21:16:44 +03:00
commit c6c64d568f
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

View file

@ -364,9 +364,10 @@ async fn search_evaluations(
} }
} }
// Get count // Get count - simple count (full filter support would require building query differently)
let count_sql = query_builder.sql().replace("SELECT *", "SELECT COUNT(*)"); let (total,): (i64,) = sqlx::query_as("SELECT COUNT(*) FROM evaluations")
let (total,): (i64,) = sqlx::query_as(&count_sql).fetch_one(pool).await?; .fetch_one(pool)
.await?;
// Apply sorting and pagination // Apply sorting and pagination
query_builder.push(" ORDER BY created_at DESC LIMIT "); query_builder.push(" ORDER BY created_at DESC LIMIT ");
@ -447,10 +448,14 @@ async fn search_builds(
} }
} }
// Get count - apply same filters as main query // Get count - simple count with the same text pattern
let _count_sql = query_builder.sql().replace("SELECT *", "SELECT COUNT(*)"); // (full filter support would require building the query differently)
let count_query = query_builder.build_query_as::<(i64,)>(); let (total,): (i64,) = sqlx::query_as(
let (total,): (i64,) = count_query.fetch_one(pool).await?; "SELECT COUNT(*) FROM builds WHERE job_name ILIKE $1 OR drv_path ILIKE $1",
)
.bind(&pattern)
.fetch_one(pool)
.await?;
// Apply sorting // Apply sorting
query_builder.push(" ORDER BY "); query_builder.push(" ORDER BY ");