Browse Source

Analytic units' panel fields are not saved to db #523 (#524)

pull/1/head
rozetko 6 years ago committed by GitHub
parent
commit
24c2e206c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      server/src/controllers/analytics_controller.ts
  2. 6
      server/src/models/analytic_unit_model.ts

5
server/src/controllers/analytics_controller.ts

@ -199,6 +199,7 @@ export async function runLearning(id: AnalyticUnit.AnalyticUnitId) {
await AnalyticUnitCache.create(id);
}
// TODO: create an analytics serialization method in AnalyticUnit
let analyticUnitType = analyticUnit.type;
let detector = AnalyticUnit.getDetectorByType(analyticUnitType);
let taskPayload: any = { detector, analyticUnitType, cache: oldCache };
@ -389,8 +390,8 @@ export async function createAnalyticUnitFromObject(obj: any): Promise<AnalyticUn
if(obj.datasource !== undefined) {
obj.metric.datasource = obj.datasource;
}
let unit: AnalyticUnit.AnalyticUnit = AnalyticUnit.AnalyticUnit.fromObject(obj);
let id = await AnalyticUnit.create(unit);
const unit: AnalyticUnit.AnalyticUnit = AnalyticUnit.AnalyticUnit.fromObject(obj);
const id = await AnalyticUnit.create(unit);
return id;
}

6
server/src/models/analytic_unit_model.ts

@ -115,7 +115,11 @@ export class AnalyticUnit {
alert: this.alert,
lastDetectionTime: this.lastDetectionTime,
status: this.status,
error: this.error
error: this.error,
labeledColor: this.labeledColor,
deletedColor: this.deletedColor,
detectorType: this.detectorType,
visible: this.visible
};
}

Loading…
Cancel
Save