make points + notes updateable
All checks were successful
CI/CD Pipeline / test (push) Successful in 3m16s
All checks were successful
CI/CD Pipeline / test (push) Successful in 3m16s
This commit is contained in:
@ -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,
|
||||
|
Reference in New Issue
Block a user