Refactor more stuff
This commit is contained in:
parent
5a7b2de0ea
commit
9394a1ae52
15 changed files with 167 additions and 86 deletions
emgauwa-lib/src/db
|
@ -40,7 +40,10 @@ pub async fn init(db: &str) -> Pool<Sqlite> {
|
|||
|
||||
run_migrations(&pool).await;
|
||||
|
||||
let mut pool_conn = pool.acquire().await.unwrap();
|
||||
let mut pool_conn = pool
|
||||
.acquire()
|
||||
.await
|
||||
.expect("Failed to acquire pool connection");
|
||||
|
||||
DbSchedule::get_on(&mut pool_conn)
|
||||
.await
|
||||
|
|
|
@ -46,8 +46,8 @@ impl Period {
|
|||
|
||||
pub fn new_on() -> Self {
|
||||
Period {
|
||||
start: NaiveTime::from_hms_opt(0, 0, 0).unwrap(),
|
||||
end: NaiveTime::from_hms_opt(0, 0, 0).unwrap(),
|
||||
start: NaiveTime::MIN,
|
||||
end: NaiveTime::MIN,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,8 +103,10 @@ impl From<Vec<u8>> for DbPeriods {
|
|||
let end_val_h: u32 = value[i - 1] as u32;
|
||||
let end_val_m: u32 = value[i] as u32;
|
||||
vec.push(Period {
|
||||
start: NaiveTime::from_hms_opt(start_val_h, start_val_m, 0).unwrap(),
|
||||
end: NaiveTime::from_hms_opt(end_val_h, end_val_m, 0).unwrap(),
|
||||
start: NaiveTime::from_hms_opt(start_val_h, start_val_m, 0)
|
||||
.expect("Failed to parse period start time from database"),
|
||||
end: NaiveTime::from_hms_opt(end_val_h, end_val_m, 0)
|
||||
.expect("Failed to parse period end time from database"),
|
||||
});
|
||||
}
|
||||
DbPeriods(vec)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue