diff --git a/server/src/controllers/analytics_controller.ts b/server/src/controllers/analytics_controller.ts index 682df96..f6218c3 100644 --- a/server/src/controllers/analytics_controller.ts +++ b/server/src/controllers/analytics_controller.ts @@ -458,6 +458,7 @@ export async function updateThreshold( export async function runLearningWithDetection(id: AnalyticUnit.AnalyticUnitId) { // TODO: move setting status somehow "inside" learning await AnalyticUnit.setStatus(id, AnalyticUnit.AnalyticUnitStatus.PENDING); + await Detection.clearSpans(id); runLearning(id) .then(() => runDetect(id)) .catch(err => console.error(err)); diff --git a/server/src/models/detection_model.ts b/server/src/models/detection_model.ts index 27f786a..e52a869 100644 --- a/server/src/models/detection_model.ts +++ b/server/src/models/detection_model.ts @@ -138,3 +138,7 @@ export function getSpanBorders(spans: DetectionSpan[]): number[] { return spanBorders; } + +export function clearSpans(analyticUnitId: AnalyticUnitId) { + return db.removeMany({ analyticUnitId }); +}