diff --git a/server/src/services/analytic_service/analytic_service.rs b/server/src/services/analytic_service/analytic_service.rs index 9f2592d..66e8c14 100644 --- a/server/src/services/analytic_service/analytic_service.rs +++ b/server/src/services/analytic_service/analytic_service.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use super::analytic_unit::types::{AnalyticUnitConfig, PatchConfig}; use super::detection_runner::DetectionRunner; -use super::types::{self, AnalyticUnitRF, DetectionRunnerConfig, LearningWaiter, HSR}; +use super::types::{self, AnalyticUnitRF, DetectionRunnerConfig, LearningWaiter, HSR, DetectionRunnerTask}; use super::{ analytic_client::AnalyticClient, types::{AnalyticServiceMessage, LearningStatus, RequestType, ResponseType}, @@ -20,6 +20,7 @@ use crate::services::analytic_service::analytic_unit::types::{AnalyticUnit, Lear use anyhow; +use chrono::{TimeZone, DateTime, Utc}; use tokio::sync::{mpsc, oneshot}; // TODO: now it's basically single analytic unit, service will operate on many AU @@ -109,7 +110,12 @@ impl AnalyticService { } if self.analytic_unit_learning_status != LearningStatus::Ready { - // TODO: add to waiter + let now: DateTime = Utc::now(); + let from = now.timestamp() as u64; + let task = DetectionRunnerTask { + from: from + } + self.learning_waiters.push(LearningWaiter::DetectionRunner(task)); return; } diff --git a/server/src/services/analytic_service/types.rs b/server/src/services/analytic_service/types.rs index 2b702a9..880d634 100644 --- a/server/src/services/analytic_service/types.rs +++ b/server/src/services/analytic_service/types.rs @@ -63,6 +63,12 @@ pub struct DetectionTask { pub to: u64, } +#[derive(Debug)] +pub struct DetectionRunnerTask { + pub from: u64, +} + + #[derive(Debug, Serialize)] pub struct AnomalyHSRConfig { pub timestamp: u64, @@ -88,6 +94,7 @@ pub struct HSRTask { #[derive(Debug)] pub enum LearningWaiter { Detection(DetectionTask), + DetectionRunner(DetectionRunnerTask), HSR(HSRTask), }