add weather infos
Some checks failed
CI/CD Pipeline / test (push) Failing after 4m16s
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled

This commit is contained in:
2024-05-16 14:41:15 +02:00
parent d6ecd87593
commit e4ef1f1584
9 changed files with 224 additions and 6 deletions

View File

@ -1,4 +1,5 @@
mod waterlevel;
mod weather;
use std::time::Duration;
@ -6,11 +7,15 @@ use job_scheduler_ng::{Job, JobScheduler};
use rocket::tokio::{self, task, time};
use sqlx::SqlitePool;
pub fn schedule(db: &SqlitePool) {
use crate::tera::Config;
pub fn schedule(db: &SqlitePool, config: &Config) {
let db = db.clone();
let openweathermap_key = config.openweathermap_key.clone();
tokio::task::spawn(async {
waterlevel::update(&db).await.unwrap();
weather::update(&db, &openweathermap_key).await.unwrap();
let mut sched = JobScheduler::new();
@ -22,6 +27,9 @@ pub fn schedule(db: &SqlitePool) {
task::block_in_place(|| {
tokio::runtime::Handle::current().block_on(async {
waterlevel::update(&db_clone).await.unwrap();
weather::update(&db_clone, &openweathermap_key)
.await
.unwrap();
});
});
}));