Browse Source

update active config begin

active-analytic-unit-#66
Alexey Velikiy 2 years ago
parent
commit
3313a92039
  1. 11
      server/src/services/analytic_service/analytic_service.rs
  2. 13
      server/src/services/analytic_unit_service.rs

11
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
}

13
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(());
}
}
Loading…
Cancel
Save