implementing get endpoint for alarms wip

This commit is contained in:
2026-03-03 10:00:46 +01:00
parent d8416f3c99
commit a7947a31bc
4 changed files with 70 additions and 24 deletions

View File

@@ -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();
}