Browse Source

Error: Can`t find cache for analytic unit #772 (#776)

pull/1/head
Alexandr Velikiy 5 years ago committed by rozetko
parent
commit
8f95415797
  1. 7
      server/src/models/analytic_unit_cache_model.ts
  2. 16
      server/src/models/segment_model.ts

7
server/src/models/analytic_unit_cache_model.ts

@ -49,8 +49,11 @@ export class AnalyticUnitCache {
return 3 * MILLISECONDS_IN_INDEX; return 3 * MILLISECONDS_IN_INDEX;
} }
public getTimeStep(): number { public get timeStep(): number | undefined {
return this.data.timeStep; if(this.data !== undefined) {
return this.data.timeStep;
}
return undefined;
} }
} }

16
server/src/models/segment_model.ts

@ -151,10 +151,6 @@ export async function mergeAndInsertSegments(segments: Segment[]): Promise<{
} }
const cache = await AnalyticUnitCache.findById(analyticUnitId); const cache = await AnalyticUnitCache.findById(analyticUnitId);
if(cache === null) {
throw new Error('Can`t find cache for analytic unit ' + analyticUnitId);
}
const detector = unit.detectorType; const detector = unit.detectorType;
let segmentIdsToRemove: SegmentId[] = []; let segmentIdsToRemove: SegmentId[] = [];
@ -180,10 +176,16 @@ export async function mergeAndInsertSegments(segments: Segment[]): Promise<{
deleted: segment.deleted deleted: segment.deleted
}); });
} else { } else {
const timeStep = cache.getTimeStep(); let intersectionRangeExtension = 0;
if(cache !== null) {
const timeStep = cache.timeStep;
if(timeStep !== undefined) {
intersectionRangeExtension = timeStep;
}
}
intersectedSegments = await findMany(analyticUnitId, { intersectedSegments = await findMany(analyticUnitId, {
to: { $gte: segment.from - timeStep }, to: { $gte: segment.from - intersectionRangeExtension },
from: { $lte: segment.to + timeStep }, from: { $lte: segment.to + intersectionRangeExtension },
labeled: segment.labeled, labeled: segment.labeled,
deleted: segment.deleted deleted: segment.deleted
}); });

Loading…
Cancel
Save