implementing get endpoint for alarms wip
This commit is contained in:
@@ -2,9 +2,9 @@ use std::sync::{Arc, Mutex};
|
||||
|
||||
use chrono::{DateTime, Local, Timelike};
|
||||
use cron_tab::Cron;
|
||||
use sea_orm::DatabaseConnection;
|
||||
use sea_orm::{DatabaseConnection, DbErr};
|
||||
|
||||
use crate::dao::alarm::create_alarm;
|
||||
use crate::dao::alarm::{self, create_alarm, get_alarms};
|
||||
use crate::ringer::Ringer;
|
||||
use crate::types::Alarm;
|
||||
|
||||
@@ -62,6 +62,10 @@ impl Scheduler {
|
||||
Ok(alarm)
|
||||
}
|
||||
|
||||
pub async fn get_alarms(&self, enabled: Option<bool>) -> Result<Vec<Alarm>, DbErr> {
|
||||
get_alarms(&*self.db, enabled).await.map(|a| a.into())
|
||||
}
|
||||
|
||||
pub fn start(&self) {
|
||||
self.cron.lock().expect("Failed to lock cron").start();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user