diff --git a/server/src/controllers/analytics_controller.ts b/server/src/controllers/analytics_controller.ts index 50380c2..e19e25b 100644 --- a/server/src/controllers/analytics_controller.ts +++ b/server/src/controllers/analytics_controller.ts @@ -206,7 +206,10 @@ export async function runLearning(id: AnalyticUnit.AnalyticUnitId, from?: number if(analyticUnit.status === AnalyticUnit.AnalyticUnitStatus.LEARNING) { throw new Error('Can`t start learning when it`s already started [' + id + ']'); } - + const oldSegments = await Segment.findMany(id, { labeled: false, deleted: false }); + // TODO: segments and spans are coupled. So their removing should be a transaction + await Segment.removeSegments(oldSegments.map(segment => segment.id)); + await Detection.clearSpans(id); let oldCache = await AnalyticUnitCache.findById(id); if(oldCache !== null) { oldCache = oldCache.data;