diff --git a/server/src/api/mod.rs b/server/src/api/mod.rs index b029890..3a9389e 100644 --- a/server/src/api/mod.rs +++ b/server/src/api/mod.rs @@ -32,7 +32,6 @@ pub struct API<'a> { user_service: Arc>, metric_service: metric_service::MetricService, segments_service: segments_service::SegmentsService, - } impl API<'_> { @@ -70,8 +69,8 @@ impl API<'_> { } pub async fn serve(&self) { - - let mut analytic_service = AnalyticService::new(self.metric_service.clone(), self.segments_service.clone()); + let mut analytic_service = + AnalyticService::new(self.metric_service.clone(), self.segments_service.clone()); let not_found = warp::any().map(|| warp::reply::with_status("Not found", StatusCode::NOT_FOUND)); @@ -95,12 +94,10 @@ impl API<'_> { .and(login.or(metrics).or(segments).or(analytics).or(options)) .or(public) .or(not_found); - - let s1= analytic_service.serve(); - let s2 = warp::serve(routes) - .run(([127, 0, 0, 1], self.config.port)); - + + let s1 = analytic_service.serve(); + let s2 = warp::serve(routes).run(([127, 0, 0, 1], self.config.port)); + futures::future::join(s1, s2).await; - } } diff --git a/server/src/services/analytic_service/analytic_service.rs b/server/src/services/analytic_service/analytic_service.rs index 450adac..14a9cac 100644 --- a/server/src/services/analytic_service/analytic_service.rs +++ b/server/src/services/analytic_service/analytic_service.rs @@ -50,7 +50,6 @@ impl AnalyticService { tx, rx, } - } pub fn get_client(&self) -> AnalyticClient { @@ -80,7 +79,10 @@ impl AnalyticService { match res { // TODO: handle when learning panic ResponseType::LearningStarted => self.learning_status = LearningStatus::Learning, - ResponseType::LearningFinished(results) => self.learning_results = Some(results), + ResponseType::LearningFinished(results) => { + self.learning_results = Some(results); + self.learning_status = LearningStatus::Ready; + } } }