2023-11-21 15:33:41 +00:00
|
|
|
use crate::db::schedules::Schedule;
|
2023-11-20 23:44:45 +00:00
|
|
|
use futures::executor;
|
2022-07-17 18:19:36 +00:00
|
|
|
use serde::Serialize;
|
2023-11-21 02:42:33 +00:00
|
|
|
use sqlx::pool::PoolConnection;
|
|
|
|
use sqlx::Sqlite;
|
2022-04-02 23:35:51 +00:00
|
|
|
|
|
|
|
#[derive(Debug, Serialize)]
|
|
|
|
pub struct ReturnSchedule {
|
2022-07-19 22:38:09 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub schedule: Schedule,
|
|
|
|
pub tags: Vec<String>,
|
2022-04-02 23:35:51 +00:00
|
|
|
}
|
|
|
|
|
2023-11-20 23:44:45 +00:00
|
|
|
impl ReturnSchedule {
|
2023-11-21 02:42:33 +00:00
|
|
|
pub fn load_tags(&mut self, conn: &mut PoolConnection<Sqlite>) {
|
2023-11-21 15:33:41 +00:00
|
|
|
self.tags = executor::block_on(self.schedule.get_tags(conn)).unwrap();
|
2023-11-20 23:44:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-02 23:35:51 +00:00
|
|
|
impl From<Schedule> for ReturnSchedule {
|
2022-07-19 22:38:09 +00:00
|
|
|
fn from(schedule: Schedule) -> Self {
|
2023-11-21 02:42:33 +00:00
|
|
|
ReturnSchedule {
|
|
|
|
schedule,
|
|
|
|
tags: vec![],
|
|
|
|
}
|
2022-07-19 22:38:09 +00:00
|
|
|
}
|
2022-07-17 18:19:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<&Schedule> for ReturnSchedule {
|
2022-07-19 22:38:09 +00:00
|
|
|
fn from(schedule: &Schedule) -> Self {
|
|
|
|
ReturnSchedule::from(schedule.clone())
|
|
|
|
}
|
2022-07-17 18:19:36 +00:00
|
|
|
}
|