Browse Source

get_active++

active-analytic-unit-#66
Alexey Velikiy 2 years ago
parent
commit
311e5a8041
  1. 18
      server/src/services/analytic_unit_service.rs

18
server/src/services/analytic_unit_service.rs

@ -53,7 +53,7 @@ impl AnalyticUnitService {
let res = stmt.exists(params![id])?;
if res == false {
// TODO: save default
// TODO: save default
conn.execute(
"INSERT INTO analytic_unit (id) VALUES (?1)",
params![id]
@ -73,7 +73,21 @@ impl AnalyticUnitService {
Ok(())
}
pub fn get_active() {
pub fn get_active(&self) -> anyhow::Result<Box<dyn types::AnalyticUnit + Send + Sync>> {
let conn = self.connection.lock().unwrap();
let stmt = conn.prepare(
"SELECT id, type, config from analytic_unit WHERE active = TRUE"
)?;
// stmt.query_row([], |row| {
// // resolve_au()
// });
// TODO: use serde to deserialise config
return Err(anyhow::format_err!("bot implemented"));
// TODO: query by id
// TODO: deserialisation of analytic_unit by config and it's type
}

Loading…
Cancel
Save