add weather infos
This commit is contained in:
@ -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();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
Reference in New Issue
Block a user