Whoops, didn't commit for a while. Added button toggling logic, doesn't work

This commit is contained in:
D. Scott Boggs 2023-06-20 08:40:35 -04:00
parent da4f4ba151
commit a60a4c4885
21 changed files with 353 additions and 106 deletions

View file

@ -10,6 +10,7 @@ use serde::{Deserialize, Serialize};
#[sea_orm(table_name = "ticks")]
pub struct Model {
#[sea_orm(primary_key)]
#[serde(skip_deserializing)]
pub id: i32,
pub track_id: Option<i32>,
pub year: Option<i32>,
@ -62,4 +63,24 @@ impl ActiveModel {
..default()
}
}
pub(crate) fn on(date: Date, track_id: i32) -> Self {
use sea_orm::ActiveValue::Set;
let now = Utc::now();
Self {
track_id: Set(Some(track_id)),
year: Set(Some(date.year())),
month: Set(date.month().try_into().ok()),
/* ^^^^^^^^^^^^^^^^^^^^^^^
* I can't imagine a situation where this doesn't fit. This way, at
* least, if it fails, you just get a messed up database entry that
* doesn't do anything bad
*/
day: Set(date.day().try_into().ok()),
hour: Set(now.hour().try_into().ok()),
minute: Set(now.minute().try_into().ok()),
second: Set(now.second().try_into().ok()),
has_time_info: Set(Some(1)),
..default()
}
}
}

View file

@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize};
#[sea_orm(table_name = "tracks")]
pub struct Model {
#[sea_orm(primary_key)]
#[serde(skip_deserializing)]
pub id: i32,
pub name: String,
pub description: String,