From 1faee92748277464546c30bb9dc45ac28e356ca9 Mon Sep 17 00:00:00 2001 From: Vivek Kumar Date: Tue, 12 Sep 2023 10:35:55 +0530 Subject: [PATCH] struct destructuring for HealthAggregator --- meilisearch/src/analytics/segment_analytics.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/meilisearch/src/analytics/segment_analytics.rs b/meilisearch/src/analytics/segment_analytics.rs index 88800669f..d7fea000e 100644 --- a/meilisearch/src/analytics/segment_analytics.rs +++ b/meilisearch/src/analytics/segment_analytics.rs @@ -1570,17 +1570,19 @@ impl HealthAggregator { ret } - /// Aggregate one [DocumentsAggregator] into another. + /// Aggregate one [HealthAggregator] into another. pub fn aggregate(&mut self, other: Self) { + let Self { timestamp, user_agents, total_received } = other; + if self.timestamp.is_none() { - self.timestamp = other.timestamp; + self.timestamp = timestamp; } // we can't create a union because there is no `into_union` method - for user_agent in other.user_agents { + for user_agent in user_agents { self.user_agents.insert(user_agent); } - self.total_received = self.total_received.saturating_add(other.total_received); + self.total_received = self.total_received.saturating_add(total_received); } pub fn into_event(self, user: &User, event_name: &str) -> Option {