get endpoint works

This commit is contained in:
2026-03-03 12:14:39 +01:00
parent 3db69454e4
commit 0ad039a597
5 changed files with 42 additions and 25 deletions

View File

@@ -1,6 +1,6 @@
use std::sync::{Arc, Mutex};
use chrono::{DateTime, Local, Timelike};
use chrono::{DateTime, Local, Timelike, Utc};
use cron_tab::Cron;
use sea_orm::{DatabaseConnection, DbErr};
@@ -48,7 +48,7 @@ impl Scheduler {
Ok(())
}
pub async fn add_alarm(&self, time: DateTime<Local>) -> Result<Alarm, String> {
pub async fn add_alarm(&self, time: DateTime<Utc>) -> Result<Alarm, String> {
let cron_schedule = format!("{} {} {} * * *", "*", time.minute(), time.hour());
let alarm = Alarm::new(true, time);
@@ -63,7 +63,12 @@ impl Scheduler {
}
pub async fn get_alarms(&self, enabled: Option<bool>) -> Result<Vec<Alarm>, DbErr> {
get_alarms(&*self.db, enabled).await.map(|a| a.into())
get_alarms(&*self.db, enabled).await
.map(|alarms| alarms
.into_iter()
.map(|a| a.into())
.collect()
)
}
pub fn start(&self) {