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. 5
      server/src/models/analytic_unit_cache_model.ts
  2. 16
      server/src/models/segment_model.ts

5
server/src/models/analytic_unit_cache_model.ts

@ -49,9 +49,12 @@ export class AnalyticUnitCache {
return 3 * MILLISECONDS_IN_INDEX;
}
public getTimeStep(): number {
public get timeStep(): number | undefined {
if(this.data !== undefined) {
return this.data.timeStep;
}
return undefined;
}
}
export async function findById(id: AnalyticUnitId): Promise<AnalyticUnitCache | null> {

16
server/src/models/segment_model.ts

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

Loading…
Cancel
Save