From 187ec15f1bca6ba08fced4242bbc5c1de9969552 Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Wed, 22 Dec 2021 18:13:55 +0300 Subject: [PATCH 01/13] active analytic unit begin --- server/src/services/analytic_service/analytic_service.rs | 3 ++- server/src/services/analytic_unit_service.rs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/server/src/services/analytic_service/analytic_service.rs b/server/src/services/analytic_service/analytic_service.rs index 090f108..d59bfca 100644 --- a/server/src/services/analytic_service/analytic_service.rs +++ b/server/src/services/analytic_service/analytic_service.rs @@ -70,6 +70,7 @@ impl AnalyticService { // TODO: get it from persistance analytic_unit: None, + // TODO: get pattern from saved in analytic_unit_service analytic_unit_config: AnalyticUnitConfig::Pattern(Default::default()), analytic_unit_learning_status: LearningStatus::Initialization, @@ -275,7 +276,7 @@ impl AnalyticService { self.analytic_unit_config = new_conf; if need_learning { self.consume_request(RequestType::RunLearning); - // TODO: it's not fullu correct: we need to wait when the learning starts + // TODO: it's not fully correct: we need to wait when the learning starts match tx.send(()) { Ok(_) => {} Err(_e) => { diff --git a/server/src/services/analytic_unit_service.rs b/server/src/services/analytic_unit_service.rs index 06532b1..786e38f 100644 --- a/server/src/services/analytic_unit_service.rs +++ b/server/src/services/analytic_unit_service.rs @@ -20,6 +20,7 @@ impl AnalyticUnitService { "CREATE TABLE IF NOT EXISTS analytic_unit ( id TEXT PRIMARY KEY, last_detection INTEGER + active BOOLEAN )", [], )?; @@ -67,4 +68,8 @@ impl AnalyticUnitService { )?; Ok(()) } + + pub fn get_active() { + + } } \ No newline at end of file From d23af0482b26b6d48e56cd5dbfa2ff2e5f5b5749 Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Wed, 22 Dec 2021 18:32:44 +0300 Subject: [PATCH 02/13] TODOS and type field --- server/src/services/analytic_unit_service.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/src/services/analytic_unit_service.rs b/server/src/services/analytic_unit_service.rs index 786e38f..9e8caae 100644 --- a/server/src/services/analytic_unit_service.rs +++ b/server/src/services/analytic_unit_service.rs @@ -21,6 +21,8 @@ impl AnalyticUnitService { id TEXT PRIMARY KEY, last_detection INTEGER active BOOLEAN + type INTEGER + config TEXT )", [], )?; @@ -70,6 +72,7 @@ impl AnalyticUnitService { } pub fn get_active() { - + // TODO: query by id + // TODO: deserialisation of analytic_unit by config and it's type } } \ No newline at end of file From 1565c156e094c12aee20d7d390658dd71aaa7bad Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Wed, 22 Dec 2021 18:43:14 +0300 Subject: [PATCH 03/13] TODO++ --- server/src/services/analytic_unit_service.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/services/analytic_unit_service.rs b/server/src/services/analytic_unit_service.rs index 9e8caae..bc85508 100644 --- a/server/src/services/analytic_unit_service.rs +++ b/server/src/services/analytic_unit_service.rs @@ -41,6 +41,7 @@ impl AnalyticUnitService { } } + // TODO: get id of analytic_unit which be used also as it's type pub fn resolve(&self, cfg: AnalyticUnitConfig) -> anyhow::Result> { let au = self.resolve_au(cfg); let id = au.as_ref().get_id(); @@ -52,6 +53,7 @@ impl AnalyticUnitService { let res = stmt.exists(params![id])?; if res == false { + // TODO: save default conn.execute( "INSERT INTO analytic_unit (id) VALUES (?1)", params![id] From 311e5a80410f183c445135d70eea501ba9920e0c Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Wed, 22 Dec 2021 19:06:04 +0300 Subject: [PATCH 04/13] get_active++ --- server/src/services/analytic_unit_service.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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 } From b26d36fad2ba8d145221ae52e5e635b8d599f3d2 Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Thu, 23 Dec 2021 10:56:12 +0300 Subject: [PATCH 05/13] serialize config in analytic_unit --- server/src/services/analytic_unit_service.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/src/services/analytic_unit_service.rs b/server/src/services/analytic_unit_service.rs index be5f4d2..f09fa6e 100644 --- a/server/src/services/analytic_unit_service.rs +++ b/server/src/services/analytic_unit_service.rs @@ -1,4 +1,6 @@ use std::sync::{Arc, Mutex}; +use serde_json::{Result, Value}; +use serde::{Deserialize, Serialize}; use rusqlite::{params, Connection}; @@ -33,7 +35,7 @@ impl AnalyticUnitService { } // TODO: optional id - pub fn resolve_au(&self, cfg: AnalyticUnitConfig) -> Box { + pub fn resolve_au(&self, cfg: &AnalyticUnitConfig) -> Box { match cfg { AnalyticUnitConfig::Threshold(c) => Box::new(ThresholdAnalyticUnit::new("1".to_string(), c.clone())), AnalyticUnitConfig::Pattern(c) => Box::new(PatternAnalyticUnit::new("2".to_string(), c.clone())), @@ -43,7 +45,7 @@ impl AnalyticUnitService { // TODO: get id of analytic_unit which be used also as it's type pub fn resolve(&self, cfg: AnalyticUnitConfig) -> anyhow::Result> { - let au = self.resolve_au(cfg); + let au = self.resolve_au(&cfg); let id = au.as_ref().get_id(); let conn = self.connection.lock().unwrap(); @@ -54,9 +56,11 @@ impl AnalyticUnitService { if res == false { // TODO: save default + // TODO: save serialised config + let cfg_json = serde_json::to_string(&cfg)?; conn.execute( - "INSERT INTO analytic_unit (id) VALUES (?1)", - params![id] + "INSERT INTO analytic_unit (id, type, config) VALUES (?1, ?1, ?2)", + params![id, cfg_json] )?; } From 86a1f7e3a610779a6e458f40a7a4e72189510aaf Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Thu, 23 Dec 2021 11:37:20 +0300 Subject: [PATCH 06/13] get active with config --- server/src/services/analytic_unit_service.rs | 28 +++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/server/src/services/analytic_unit_service.rs b/server/src/services/analytic_unit_service.rs index f09fa6e..5ce19cb 100644 --- a/server/src/services/analytic_unit_service.rs +++ b/server/src/services/analytic_unit_service.rs @@ -55,8 +55,6 @@ impl AnalyticUnitService { let res = stmt.exists(params![id])?; if res == false { - // TODO: save default - // TODO: save serialised config let cfg_json = serde_json::to_string(&cfg)?; conn.execute( "INSERT INTO analytic_unit (id, type, config) VALUES (?1, ?1, ?2)", @@ -64,6 +62,15 @@ impl AnalyticUnitService { )?; } + conn.execute( + "UPDATE analytic_unit set active = FALSE where active = TRUE", + params![] + )?; + conn.execute( + "UPDATE analytic_unit set active = TRUE where id = ?1", + params![id] + )?; + return Ok(au); } @@ -79,20 +86,17 @@ impl AnalyticUnitService { pub fn get_active(&self) -> anyhow::Result> { let conn = self.connection.lock().unwrap(); - let stmt = conn.prepare( + let mut stmt = conn.prepare( "SELECT id, type, config from analytic_unit WHERE active = TRUE" )?; - // stmt.query_row([], |row| { + let au = stmt.query_row([], |row| { + let c: String = row.get(2)?; + let cfg = serde_json::from_str(&c).unwrap(); + Ok(self.resolve(cfg)) + })?; - // // resolve_au() - // }); - - // TODO: use serde to deserialise config + return Ok(au); - return Err(anyhow::format_err!("bot implemented")); - - // TODO: query by id - // TODO: deserialisation of analytic_unit by config and it's type } } \ No newline at end of file From 090b9bf42eee9c0be513c04b503e8562ca2e4fc6 Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Thu, 23 Dec 2021 12:47:25 +0300 Subject: [PATCH 07/13] active config++ --- .../analytic_service/analytic_service.rs | 13 +++++-- server/src/services/analytic_unit_service.rs | 38 ++++++++++++++----- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/server/src/services/analytic_service/analytic_service.rs b/server/src/services/analytic_service/analytic_service.rs index 6b2471f..41947f3 100644 --- a/server/src/services/analytic_service/analytic_service.rs +++ b/server/src/services/analytic_service/analytic_service.rs @@ -23,7 +23,7 @@ use crate::services::analytic_service::analytic_unit::types::{AnalyticUnit, Lear use anyhow; -use chrono::{DateTime, TimeZone, Utc}; +use chrono::{DateTime, Utc}; use tokio::sync::{mpsc, oneshot}; // TODO: now it's basically single analytic unit, service will operate on many AU @@ -59,10 +59,14 @@ impl AnalyticService { segments_service: segments_service::SegmentsService, alerting: Option, ) -> AnalyticService { + + // TODO: move buffer size to config let (tx, rx) = mpsc::channel::(32); + let aus = analytic_unit_service.clone(); + AnalyticService { - analytic_unit_service, + analytic_unit_service: aus, metric_service, segments_service, @@ -71,7 +75,7 @@ impl AnalyticService { // TODO: get it from persistance analytic_unit: None, // TODO: get pattern from saved in analytic_unit_service - analytic_unit_config: AnalyticUnitConfig::Pattern(Default::default()), + analytic_unit_config: analytic_unit_service.get_active_config().unwrap(), analytic_unit_learning_status: LearningStatus::Initialization, tx, @@ -272,6 +276,7 @@ impl AnalyticService { } fn patch_config(&mut self, patch: PatchConfig, tx: oneshot::Sender<()>) { + // TODO: update config in db let (new_conf, need_learning) = self.analytic_unit_config.patch(patch); self.analytic_unit_config = new_conf; if need_learning { @@ -334,7 +339,7 @@ impl AnalyticService { ms: MetricService, ss: SegmentsService, ) { - let mut au = match aus.resolve(aucfg) { + let mut au = match aus.resolve(&aucfg) { Ok(a) => a, Err(e) => { panic!("{}", e); } }; diff --git a/server/src/services/analytic_unit_service.rs b/server/src/services/analytic_unit_service.rs index 5ce19cb..e7f3543 100644 --- a/server/src/services/analytic_unit_service.rs +++ b/server/src/services/analytic_unit_service.rs @@ -21,9 +21,9 @@ impl AnalyticUnitService { conn.execute( "CREATE TABLE IF NOT EXISTS analytic_unit ( id TEXT PRIMARY KEY, - last_detection INTEGER - active BOOLEAN - type INTEGER + last_detection INTEGER, + active BOOLEAN, + type INTEGER, config TEXT )", [], @@ -44,8 +44,8 @@ impl AnalyticUnitService { } // TODO: get id of analytic_unit which be used also as it's type - pub fn resolve(&self, cfg: AnalyticUnitConfig) -> anyhow::Result> { - let au = self.resolve_au(&cfg); + pub fn resolve(&self, cfg: &AnalyticUnitConfig) -> anyhow::Result> { + let au = self.resolve_au(cfg); let id = au.as_ref().get_id(); let conn = self.connection.lock().unwrap(); @@ -74,7 +74,6 @@ impl AnalyticUnitService { return Ok(au); } - // TODO: resolve with saving by id pub fn set_last_detection(&self, id: String, last_detection: u64) -> anyhow::Result<()> { let conn = self.connection.lock().unwrap(); conn.execute( @@ -85,6 +84,7 @@ impl AnalyticUnitService { } pub fn get_active(&self) -> anyhow::Result> { + // TODO: return default when there is no active let conn = self.connection.lock().unwrap(); let mut stmt = conn.prepare( "SELECT id, type, config from analytic_unit WHERE active = TRUE" @@ -92,11 +92,31 @@ impl AnalyticUnitService { let au = stmt.query_row([], |row| { let c: String = row.get(2)?; - let cfg = serde_json::from_str(&c).unwrap(); - Ok(self.resolve(cfg)) - })?; + let cfg: AnalyticUnitConfig = serde_json::from_str(&c).unwrap(); + Ok(self.resolve(&cfg)) + })??; return Ok(au); } + + pub fn get_active_config(&self) -> anyhow::Result { + let conn = self.connection.lock().unwrap(); + let mut stmt = conn.prepare( + "SELECT config from analytic_unit WHERE active = TRUE" + )?; + + if stmt.exists([])? == false { + let c = AnalyticUnitConfig::Pattern(Default::default()); + self.resolve(&c)?; + return Ok(c); + } else { + let acfg = stmt.query_row([], |row| { + let c: String = row.get(0)?; + let cfg = serde_json::from_str(&c).unwrap(); + Ok(cfg) + })?; + return Ok(acfg); + } + } } \ No newline at end of file From 5bf13b171b188f8f3eb672e655269ab5f49ec6c2 Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Thu, 23 Dec 2021 12:53:46 +0300 Subject: [PATCH 08/13] get_active_config++ --- server/src/services/analytic_unit_service.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/server/src/services/analytic_unit_service.rs b/server/src/services/analytic_unit_service.rs index e7f3543..8f5a5c0 100644 --- a/server/src/services/analytic_unit_service.rs +++ b/server/src/services/analytic_unit_service.rs @@ -101,16 +101,23 @@ impl AnalyticUnitService { } pub fn get_active_config(&self) -> anyhow::Result { - let conn = self.connection.lock().unwrap(); - let mut stmt = conn.prepare( - "SELECT config from analytic_unit WHERE active = TRUE" - )?; + let exists = { + let conn = self.connection.lock().unwrap(); + let mut stmt = conn.prepare( + "SELECT config from analytic_unit WHERE active = TRUE" + )?; + stmt.exists([])? + }; - if stmt.exists([])? == false { + if exists == false { let c = AnalyticUnitConfig::Pattern(Default::default()); self.resolve(&c)?; return Ok(c); } else { + let conn = self.connection.lock().unwrap(); + let mut stmt = conn.prepare( + "SELECT config from analytic_unit WHERE active = TRUE" + )?; let acfg = stmt.query_row([], |row| { let c: String = row.get(0)?; let cfg = serde_json::from_str(&c).unwrap(); From 1f2d6f551ebb10cf243adb6be95a48740be67984 Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Thu, 23 Dec 2021 13:07:07 +0300 Subject: [PATCH 09/13] patch config: same type param --- .../analytic_service/analytic_service.rs | 6 ++-- .../analytic_service/analytic_unit/types.rs | 28 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/server/src/services/analytic_service/analytic_service.rs b/server/src/services/analytic_service/analytic_service.rs index 41947f3..aba5a6f 100644 --- a/server/src/services/analytic_service/analytic_service.rs +++ b/server/src/services/analytic_service/analytic_service.rs @@ -72,9 +72,7 @@ impl AnalyticService { alerting, - // TODO: get it from persistance analytic_unit: None, - // TODO: get pattern from saved in analytic_unit_service analytic_unit_config: analytic_unit_service.get_active_config().unwrap(), analytic_unit_learning_status: LearningStatus::Initialization, @@ -277,7 +275,7 @@ impl AnalyticService { fn patch_config(&mut self, patch: PatchConfig, tx: oneshot::Sender<()>) { // TODO: update config in db - let (new_conf, need_learning) = self.analytic_unit_config.patch(patch); + let (new_conf, need_learning, same_type) = self.analytic_unit_config.patch(patch); self.analytic_unit_config = new_conf; if need_learning { self.consume_request(RequestType::RunLearning); @@ -312,6 +310,8 @@ impl AnalyticService { } } } + + // TODO: save config depending on type } pub async fn serve(&mut self) { diff --git a/server/src/services/analytic_service/analytic_unit/types.rs b/server/src/services/analytic_service/analytic_unit/types.rs index b591d94..2ae8221 100644 --- a/server/src/services/analytic_service/analytic_unit/types.rs +++ b/server/src/services/analytic_service/analytic_unit/types.rs @@ -63,22 +63,22 @@ pub enum AnalyticUnitConfig { } impl AnalyticUnitConfig { - // return true if patch is different type - pub fn patch(&self, patch: PatchConfig) -> (AnalyticUnitConfig, bool) { + // return true if need needs relearning and true if the config of the same type + pub fn patch(&self, patch: PatchConfig) -> (AnalyticUnitConfig, bool, bool) { match patch { PatchConfig::Pattern(tcfg) => match self.clone() { AnalyticUnitConfig::Pattern(_) => { if tcfg.is_some() { - return (AnalyticUnitConfig::Pattern(tcfg.unwrap()), false); + return (AnalyticUnitConfig::Pattern(tcfg.unwrap()), false, true); } else { - return (AnalyticUnitConfig::Pattern(Default::default()), false); + return (AnalyticUnitConfig::Pattern(Default::default()), false, true); } } _ => { if tcfg.is_some() { - return (AnalyticUnitConfig::Pattern(tcfg.unwrap()), true); + return (AnalyticUnitConfig::Pattern(tcfg.unwrap()), true, false); } else { - return (AnalyticUnitConfig::Pattern(Default::default()), true); + return (AnalyticUnitConfig::Pattern(Default::default()), true, false); } } }, @@ -89,16 +89,16 @@ impl AnalyticUnitConfig { let t = tcfg.as_ref().unwrap(); let mut need_learning = t.seasonality != scfg.seasonality; need_learning |= t.seasonality_iterations != scfg.seasonality_iterations; - return (AnalyticUnitConfig::Anomaly(tcfg.unwrap()), need_learning); + return (AnalyticUnitConfig::Anomaly(tcfg.unwrap()), need_learning, true); } else { - return (AnalyticUnitConfig::Anomaly(Default::default()), false); + return (AnalyticUnitConfig::Anomaly(Default::default()), false, true); } } _ => { if tcfg.is_some() { - return (AnalyticUnitConfig::Anomaly(tcfg.unwrap()), true); + return (AnalyticUnitConfig::Anomaly(tcfg.unwrap()), true, false); } else { - return (AnalyticUnitConfig::Anomaly(Default::default()), true); + return (AnalyticUnitConfig::Anomaly(Default::default()), true, false); } } }, @@ -106,16 +106,16 @@ impl AnalyticUnitConfig { PatchConfig::Threshold(tcfg) => match self.clone() { AnalyticUnitConfig::Threshold(_) => { if tcfg.is_some() { - return (AnalyticUnitConfig::Threshold(tcfg.unwrap()), false); + return (AnalyticUnitConfig::Threshold(tcfg.unwrap()), false, true); } else { - return (AnalyticUnitConfig::Threshold(Default::default()), false); + return (AnalyticUnitConfig::Threshold(Default::default()), false, true); } } _ => { if tcfg.is_some() { - return (AnalyticUnitConfig::Threshold(tcfg.unwrap()), true); + return (AnalyticUnitConfig::Threshold(tcfg.unwrap()), true, false); } else { - return (AnalyticUnitConfig::Threshold(Default::default()), true); + return (AnalyticUnitConfig::Threshold(Default::default()), true, false); } } }, From a982f8f1f5b20e08bd64d9fff9e28953817e89c5 Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Thu, 23 Dec 2021 14:05:05 +0300 Subject: [PATCH 10/13] update_active_config begin --- server/src/services/analytic_unit_service.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/src/services/analytic_unit_service.rs b/server/src/services/analytic_unit_service.rs index 8f5a5c0..08444b2 100644 --- a/server/src/services/analytic_unit_service.rs +++ b/server/src/services/analytic_unit_service.rs @@ -126,4 +126,8 @@ impl AnalyticUnitService { return Ok(acfg); } } + + pub fn update_active_config() { + // TODO: implement + } } \ No newline at end of file From 3313a9203935fa563b08324ea954f3711f617b5a Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Thu, 23 Dec 2021 14:48:12 +0300 Subject: [PATCH 11/13] update active config begin --- .../services/analytic_service/analytic_service.rs | 11 +++++++++-- server/src/services/analytic_unit_service.rs | 13 +++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/server/src/services/analytic_service/analytic_service.rs b/server/src/services/analytic_service/analytic_service.rs index aba5a6f..326dc18 100644 --- a/server/src/services/analytic_service/analytic_service.rs +++ b/server/src/services/analytic_service/analytic_service.rs @@ -274,9 +274,9 @@ impl AnalyticService { } fn patch_config(&mut self, patch: PatchConfig, tx: oneshot::Sender<()>) { - // TODO: update config in db + let (new_conf, need_learning, same_type) = self.analytic_unit_config.patch(patch); - self.analytic_unit_config = new_conf; + self.analytic_unit_config = new_conf.clone(); if need_learning { self.consume_request(RequestType::RunLearning); // TODO: it's not fully correct: we need to wait when the learning starts @@ -311,6 +311,13 @@ impl AnalyticService { } } + if same_type { + // TODO: avoid using `unwrap` + self.analytic_unit_service.update_active_config(&new_conf).unwrap(); + } else { + // TODO: implement + } + // TODO: save config depending on type } diff --git a/server/src/services/analytic_unit_service.rs b/server/src/services/analytic_unit_service.rs index 08444b2..036ee2f 100644 --- a/server/src/services/analytic_unit_service.rs +++ b/server/src/services/analytic_unit_service.rs @@ -127,7 +127,16 @@ impl AnalyticUnitService { } } - pub fn update_active_config() { - // TODO: implement + pub fn update_active_config(&self, cfg: &AnalyticUnitConfig) -> anyhow::Result<()> { + let conn = self.connection.lock().unwrap(); + + let cfg_json = serde_json::to_string(&cfg)?; + + conn.execute( + "UPDATE analytic_unit SET config = ?1 WHERE active = TRUE", + params![cfg_json] + )?; + + return Ok(()); } } \ No newline at end of file From b5f960a6ea1a5f6498c8833f9e0d065accd527d6 Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Thu, 23 Dec 2021 15:29:38 +0300 Subject: [PATCH 12/13] save config for patched --- server/src/services/analytic_service/analytic_service.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/src/services/analytic_service/analytic_service.rs b/server/src/services/analytic_service/analytic_service.rs index 326dc18..7c007dd 100644 --- a/server/src/services/analytic_service/analytic_service.rs +++ b/server/src/services/analytic_service/analytic_service.rs @@ -311,14 +311,17 @@ impl AnalyticService { } } + if same_type { // TODO: avoid using `unwrap` self.analytic_unit_service.update_active_config(&new_conf).unwrap(); } else { - // TODO: implement + // TODO: it's a hack, make it a better way + // TODO: avoid using unwrap + self.analytic_unit_service.resolve(&new_conf).unwrap(); + self.analytic_unit_service.update_active_config(&new_conf).unwrap(); } - // TODO: save config depending on type } pub async fn serve(&mut self) { From 2498c40bed169e41c3c3725a33a766e6a6620467 Mon Sep 17 00:00:00 2001 From: glitch4347 <86535784+glitch4347@users.noreply.github.com> Date: Thu, 23 Dec 2021 19:11:14 +0300 Subject: [PATCH 13/13] Update server/src/services/analytic_unit_service.rs --- server/src/services/analytic_unit_service.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/services/analytic_unit_service.rs b/server/src/services/analytic_unit_service.rs index 036ee2f..bd7de52 100644 --- a/server/src/services/analytic_unit_service.rs +++ b/server/src/services/analytic_unit_service.rs @@ -139,4 +139,4 @@ impl AnalyticUnitService { return Ok(()); } -} \ No newline at end of file +}