Browse Source

set readay

pull/25/head
Alexey Velikiy 3 years ago
parent
commit
226409e692
  1. 11
      server/src/api/mod.rs
  2. 6
      server/src/services/analytic_service/analytic_service.rs

11
server/src/api/mod.rs

@ -32,7 +32,6 @@ pub struct API<'a> {
user_service: Arc<RwLock<user_service::UserService>>, user_service: Arc<RwLock<user_service::UserService>>,
metric_service: metric_service::MetricService, metric_service: metric_service::MetricService,
segments_service: segments_service::SegmentsService, segments_service: segments_service::SegmentsService,
} }
impl API<'_> { impl API<'_> {
@ -70,8 +69,8 @@ impl API<'_> {
} }
pub async fn serve(&self) { pub async fn serve(&self) {
let mut analytic_service =
let mut analytic_service = AnalyticService::new(self.metric_service.clone(), self.segments_service.clone()); AnalyticService::new(self.metric_service.clone(), self.segments_service.clone());
let not_found = let not_found =
warp::any().map(|| warp::reply::with_status("Not found", StatusCode::NOT_FOUND)); warp::any().map(|| warp::reply::with_status("Not found", StatusCode::NOT_FOUND));
@ -96,11 +95,9 @@ impl API<'_> {
.or(public) .or(public)
.or(not_found); .or(not_found);
let s1= analytic_service.serve(); let s1 = analytic_service.serve();
let s2 = warp::serve(routes) let s2 = warp::serve(routes).run(([127, 0, 0, 1], self.config.port));
.run(([127, 0, 0, 1], self.config.port));
futures::future::join(s1, s2).await; futures::future::join(s1, s2).await;
} }
} }

6
server/src/services/analytic_service/analytic_service.rs

@ -50,7 +50,6 @@ impl AnalyticService {
tx, tx,
rx, rx,
} }
} }
pub fn get_client(&self) -> AnalyticClient { pub fn get_client(&self) -> AnalyticClient {
@ -80,7 +79,10 @@ impl AnalyticService {
match res { match res {
// TODO: handle when learning panic // TODO: handle when learning panic
ResponseType::LearningStarted => self.learning_status = LearningStatus::Learning, 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;
}
} }
} }

Loading…
Cancel
Save