diff --git a/stats/stats-server/src/config/types.rs b/stats/stats-server/src/config/types.rs index db07b1e20..83f6c2b08 100644 --- a/stats/stats-server/src/config/types.rs +++ b/stats/stats-server/src/config/types.rs @@ -197,17 +197,20 @@ impl LineChartCategory { /// If the settings are not present - remove the chart (i.e. remove disabled /// or nonexistent charts) pub fn intersect_info( - self, + &self, info: &BTreeMap, ) -> proto_v1::LineChartSection { let charts: Vec<_> = self .charts_order - .into_iter() - .flat_map(|c: String| info.get(&c).map(|e| e.build_proto_line_chart_info(c))) + .iter() + .flat_map(|chart| { + info.get(chart) + .map(|e| e.build_proto_line_chart_info(chart.clone())) + }) .collect(); proto_v1::LineChartSection { - id: self.id, - title: self.title, + id: self.id.clone(), + title: self.title.clone(), charts, } } diff --git a/stats/stats-server/src/read_service.rs b/stats/stats-server/src/read_service.rs index 5600a8e3e..30aa7acb1 100644 --- a/stats/stats-server/src/read_service.rs +++ b/stats/stats-server/src/read_service.rs @@ -68,12 +68,12 @@ fn map_read_error(err: ReadError) -> Status { /// /// Returns `None` if info were not found for some chart. fn add_chart_info_to_layout( - layout: Vec, - chart_info: BTreeMap, + layout: &[types::LineChartCategory], + chart_info: &BTreeMap, ) -> Vec { layout - .into_iter() - .map(|cat| cat.intersect_info(&chart_info)) + .iter() + .map(|cat| cat.intersect_info(chart_info)) .collect() } @@ -280,9 +280,10 @@ impl StatsService for ReadService { &self, _request: Request, ) -> Result, Status> { - let layout = self.charts.lines_layout.clone(); - let info = self.charts.charts_info.clone(); - let sections = add_chart_info_to_layout(layout, info); + let sections = add_chart_info_to_layout( + self.charts.lines_layout.as_slice(), + &self.charts.charts_info, + ); Ok(Response::new(proto_v1::LineCharts { sections })) }