diff --git a/server/src/services/analytic_unit_service.rs b/server/src/services/analytic_unit_service.rs index bc85508..be5f4d2 100644 --- a/server/src/services/analytic_unit_service.rs +++ b/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> { + 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 }