struct destructuring for HealthAggregator

This commit is contained in:
Vivek Kumar 2023-09-12 10:35:55 +05:30
parent 5831466525
commit 1faee92748
No known key found for this signature in database
GPG Key ID: 5F915FFA1FD3B841

View File

@ -1570,17 +1570,19 @@ impl HealthAggregator {
ret ret
} }
/// Aggregate one [DocumentsAggregator] into another. /// Aggregate one [HealthAggregator] into another.
pub fn aggregate(&mut self, other: Self) { pub fn aggregate(&mut self, other: Self) {
let Self { timestamp, user_agents, total_received } = other;
if self.timestamp.is_none() { 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 // 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.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<Track> { pub fn into_event(self, user: &User, event_name: &str) -> Option<Track> {