From 9475a4b4429709a18440474437d360715d3e0f2f Mon Sep 17 00:00:00 2001
From: Jan Mach <jan.mach@cesnet.cz>
Date: Wed, 19 Feb 2020 14:56:19 +0100
Subject: [PATCH] Fix: Fixed issues with incorrect use or in-memory
 thresholding cache.

---
 lib/mentat/reports/utils.py | 7 ++++++-
 lib/mentat/stats/idea.py    | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/mentat/reports/utils.py b/lib/mentat/reports/utils.py
index 52e409677..df10a6be0 100644
--- a/lib/mentat/reports/utils.py
+++ b/lib/mentat/reports/utils.py
@@ -501,7 +501,12 @@ class SimpleMemoryThresholdingCache(ThresholdingCache):
         """
         *Interface implementation:* Implementation of :py:func:`mentat.reports.utils.ThresholdingCache.cleanup` method.
         """
-        return {'thresholds': 0, 'events': 0}
+        result = {
+            'thresholds': len(self.memcache),
+            'events': 0
+        }
+        self.memcache = {}
+        return result
 
 
 class SingleSourceThresholdingCache(SimpleMemoryThresholdingCache):
diff --git a/lib/mentat/stats/idea.py b/lib/mentat/stats/idea.py
index ee71bfb2c..cdc02da52 100644
--- a/lib/mentat/stats/idea.py
+++ b/lib/mentat/stats/idea.py
@@ -285,7 +285,7 @@ def evaluate_timeline_events(events, dt_from, dt_to, max_count, stats = None):
 
     for event in events:
         # Detect recurring events.
-        recurring = tcache.event_is_thresholded(event, None)
+        recurring = tcache.event_is_thresholded(event, None, None)
         tcache.set_threshold(event, None, None, None, None)
 
         # Include event into global statistics.
-- 
GitLab