Browse Source

Remove old detected segments and detection spans when learning starts #650 (#651)

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

5
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) { if(analyticUnit.status === AnalyticUnit.AnalyticUnitStatus.LEARNING) {
throw new Error('Can`t start learning when it`s already started [' + id + ']'); 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); let oldCache = await AnalyticUnitCache.findById(id);
if(oldCache !== null) { if(oldCache !== null) {
oldCache = oldCache.data; oldCache = oldCache.data;

Loading…
Cancel
Save