From 1afbe3dea51758a71936a55a51bdd80c7af0f1f1 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Tue, 28 Apr 2020 16:50:01 +0300 Subject: [PATCH] Improved ZT event aggregation performance --- .../monkey_island/cc/models/zero_trust/aggregate_finding.py | 4 ++-- monkey/monkey_island/cc/models/zero_trust/finding.py | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/monkey/monkey_island/cc/models/zero_trust/aggregate_finding.py b/monkey/monkey_island/cc/models/zero_trust/aggregate_finding.py index 38b551047..ff3c4e4d9 100644 --- a/monkey/monkey_island/cc/models/zero_trust/aggregate_finding.py +++ b/monkey/monkey_island/cc/models/zero_trust/aggregate_finding.py @@ -12,7 +12,7 @@ class AggregateFinding(Finding): :raises: Assertion error if this is used when there's more then one finding which fits the query - this is not when this function should be used. """ - existing_findings = Finding.objects(test=test, status=status) + existing_findings = Finding.objects(test=test, status=status).exclude('events') assert (len(existing_findings) < 2), "More than one finding exists for {}:{}".format(test, status) if len(existing_findings) == 0: @@ -20,7 +20,7 @@ class AggregateFinding(Finding): else: # Now we know for sure this is the only one orig_finding = existing_findings[0] - orig_finding.add_events(events) + orig_finding.update(push_all__events=events) orig_finding.save() diff --git a/monkey/monkey_island/cc/models/zero_trust/finding.py b/monkey/monkey_island/cc/models/zero_trust/finding.py index 90c9e1dc3..ae1114655 100644 --- a/monkey/monkey_island/cc/models/zero_trust/finding.py +++ b/monkey/monkey_island/cc/models/zero_trust/finding.py @@ -54,7 +54,3 @@ class Finding(Document): finding.save() return finding - - def add_events(self, events): - # type: (list) -> None - self.events.extend(events)