feat: Add previous winners field to hackathon schema and update related tests

This commit is contained in:
MythEclipse
2025-09-27 22:30:42 +07:00
parent af41a98111
commit a32f54873b
10 changed files with 128 additions and 20 deletions
+7
View File
@@ -44,6 +44,13 @@ impl ListQueryBuilder {
builder
}
pub fn with_additional_conditions(mut self, additional_conditions: &[String]) -> Self {
for condition in additional_conditions {
self.conditions.push(condition.clone());
}
self
}
pub fn new(resource: impl Into<String>) -> Self {
Self {
resource: resource.into(),
+7 -2
View File
@@ -76,7 +76,7 @@ impl<'a> QueryListBuilder<'a> {
&self.search_field,
self.select_fields,
self.fetch_fields,
);
).with_additional_conditions(&self.conditions);
let data_sql = data_query_builder.build();
// --- Count Query ---
@@ -86,7 +86,7 @@ impl<'a> QueryListBuilder<'a> {
&self.search_field,
None, // No select fields for count
None, // No fetch fields for count
);
).with_additional_conditions(&self.conditions);
let count_sql = count_query_builder.build_count();
// Combine both queries into a single query string within a transaction for a single database call
@@ -129,6 +129,11 @@ impl<'a> QueryListBuilder<'a> {
let count_result: Vec<CountResult> = response.take(1)?; // Second result is the count
let total = count_result.first().map(|c| c.count);
// Debug logging
if std::env::var("RUST_ENV").unwrap_or_else(|_| "development".to_string()) == "development" {
println!("QueryListBuilder: data length = {}, total from count = {:?}", raw.len(), total);
println!("Combined SQL: {}", combined_sql);
}
Ok(ResponseListSuccessDto {
data: raw,