diff --git a/analytics/analytics/detectors/threshold_detector.py b/analytics/analytics/detectors/threshold_detector.py index c9f8e43..3f834a7 100644 --- a/analytics/analytics/detectors/threshold_detector.py +++ b/analytics/analytics/detectors/threshold_detector.py @@ -52,7 +52,6 @@ class ThresholdDetector(Detector): elif condition == '<': if last_value < value: segments.append(segment) - log.debug('seg {}'.format(segments)) return { 'cache': cache, 'segments': segments, diff --git a/server/src/models/threshold_model.ts b/server/src/models/threshold_model.ts index 1374c7f..1649d2a 100644 --- a/server/src/models/threshold_model.ts +++ b/server/src/models/threshold_model.ts @@ -49,9 +49,7 @@ export class Threshold { } export async function findOne(id: AnalyticUnitId): Promise { - const query: any = { id }; - - const threshold = await db.findOne(query); + const threshold = await db.findOne(id); if(threshold === null) { return null; } @@ -59,11 +57,12 @@ export async function findOne(id: AnalyticUnitId): Promise { } export async function updateThreshold(id: AnalyticUnitId, value: number, condition: Condition) { - const threshold = await db.findOne(id); + let threshold = await db.findOne(id); if(threshold === null) { - return db.insertOne({ id, value, condition }); + threshold = new Threshold(id, value, condition); + return db.insertOne(threshold.toObject()); } - return db.updateOne({ id }, { value, condition }); + return db.updateOne(id, { value, condition }); } export async function removeThreshold(id: AnalyticUnitId) {