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 b6b0b86
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/graphql/queries/attendance_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,26 +140,17 @@ 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
)))
}
};
.await?;

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

Expand Down

0 comments on commit b6b0b86

Please sign in to comment.