Skip to content

Commit

Permalink
used ? to unwrap insted of using match
Browse files Browse the repository at this point in the history
  • Loading branch information
sabarixr committed Feb 28, 2025
1 parent dd0b1ce commit 29f1a39
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/graphql/queries/attendance_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,26 +140,18 @@ impl AttendanceQueries {
})
.collect();

let max_days = match sqlx::query_scalar::<_, i64>(
"SELECT COUNT(DISTINCT date) FROM Attendance
WHERE date >= CURRENT_DATE - INTERVAL '6 months' AND is_present",
let max_days = sqlx::query_scalar::<_, i64>(
"SELECT COUNT(DISTINCT date) FROM Attendance
WHERE date >= CURRENT_DATE - INTERVAL '6 months' AND is_present",
)
.fetch_one(pool.as_ref())
.await
{
Ok(count) => count,
Err(e) => {
return Err(async_graphql::Error::new(format!(
"Failed to fetch max days: {}",
e
)))
}
};
.fetch_one(pool.as_ref())
.await?;


Ok(AttendanceReport {
daily_count,
member_attendance,
max_days: max_days as i64,
max_days,
})
}

Expand Down

0 comments on commit 29f1a39

Please sign in to comment.