make points + notes updateable
All checks were successful
CI/CD Pipeline / test (push) Successful in 3m16s

This commit is contained in:
2025-04-11 19:51:01 +02:00
parent 6be4f1f883
commit 17690d7e6f
4 changed files with 182 additions and 18 deletions

View File

@ -8,7 +8,7 @@ pub(crate) struct Rating {
pub(crate) team_id: i64,
pub(crate) station_id: i64,
pub(crate) points: Option<i64>,
notes: Option<String>,
pub(crate) notes: Option<String>,
arrived_at: NaiveDateTime,
started_at: Option<NaiveDateTime>,
left_at: Option<NaiveDateTime>,
@ -30,6 +30,27 @@ impl Rating {
.map_err(|e| e.to_string())?;
Ok(())
}
pub(crate) async fn update(
db: &SqlitePool,
station: &Station,
team: &Team,
points: Option<i64>,
notes: Option<String>,
) -> Result<(), String> {
sqlx::query!(
"UPDATE rating SET points = ?, notes = ? WHERE station_id = ? AND team_id = ?",
points,
notes,
station.id,
team.id
)
.execute(db)
.await
.map_err(|e| e.to_string())?;
Ok(())
}
pub(crate) async fn delete(
db: &SqlitePool,
station: &Station,