Browse Source

Threshold value is not saving #368 (#369)

fix threshold model
pull/1/head
Evgeny Smyshlyaev 6 years ago committed by GitHub
parent
commit
fc0935c0cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      analytics/analytics/detectors/threshold_detector.py
  2. 11
      server/src/models/threshold_model.ts

1
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,

11
server/src/models/threshold_model.ts

@ -49,9 +49,7 @@ export class Threshold {
}
export async function findOne(id: AnalyticUnitId): Promise<Threshold | null> {
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<Threshold | null> {
}
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) {

Loading…
Cancel
Save