Add trait for db_model to model conversion
This commit is contained in:
parent
8dab4b9a50
commit
cb47dcda5c
5 changed files with 92 additions and 59 deletions
emgauwa-controller/src
|
@ -3,6 +3,7 @@ use std::str;
|
|||
use crate::relay_loop::run_relay_loop;
|
||||
use crate::settings::Settings;
|
||||
use emgauwa_lib::db::{DbController, DbRelay};
|
||||
use emgauwa_lib::models::convert_db_list;
|
||||
use emgauwa_lib::types::ControllerUid;
|
||||
use emgauwa_lib::{db, models};
|
||||
use futures::channel::mpsc;
|
||||
|
@ -88,10 +89,7 @@ async fn main() {
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
let relays = db_relays
|
||||
.into_iter()
|
||||
.map(|relay| models::Relay::from_db_relay(relay, &mut conn))
|
||||
.collect();
|
||||
let relays = convert_db_list(&mut conn, db_relays).expect("Failed to convert relays");
|
||||
|
||||
let this = models::Controller {
|
||||
controller: db_controller,
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
use crate::settings::Settings;
|
||||
use chrono::Local;
|
||||
use std::time::Duration;
|
||||
use tokio::time;
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub async fn run_relay_loop(settings: Settings) {
|
||||
let next_timestamp = Local::now().naive_local();
|
||||
loop {}
|
||||
let default_duration = Duration::from_millis(1000);
|
||||
loop {
|
||||
// naivetime timestamp for now
|
||||
let next_timestamp = Local::now().naive_local().time() + default_duration;
|
||||
time::sleep(default_duration).await;
|
||||
println!("Relay loop: {}", next_timestamp)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue