Fix size call.
This commit is contained in:
Vendored
+1
-1
@@ -5,5 +5,5 @@
|
|||||||
"i18n-ally.keepFulfilled": true,
|
"i18n-ally.keepFulfilled": true,
|
||||||
"i18n-ally.editor.preferEditor": true,
|
"i18n-ally.editor.preferEditor": true,
|
||||||
"i18n-ally.translate.saveAsCandidates": true,
|
"i18n-ally.translate.saveAsCandidates": true,
|
||||||
"vitest.commandLine": "npx vitest --root /home/dizer/src/frigate-hass-card"
|
"vitest.commandLine": "npx vitest --root ."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,10 @@ class MemoryRangedCache<Data> {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getSize(): number {
|
||||||
|
return this._data.length;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove old data that matches a given predicate. No change to the covered
|
* Remove old data that matches a given predicate. No change to the covered
|
||||||
* ranges is made, i.e. this is asserting authoritiatively that this data does
|
* ranges is made, i.e. this is asserting authoritiatively that this data does
|
||||||
@@ -146,8 +150,8 @@ export class RecordingSegmentsCache {
|
|||||||
return this._segments.get(cameraID)?.get(range) ?? null;
|
return this._segments.get(cameraID)?.get(range) ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCache(cameraID: string): MemoryRangedCache<RecordingSegment> | null {
|
public getSize(cameraID: string): number | null {
|
||||||
return this._segments.get(cameraID) ?? null;
|
return this._segments.get(cameraID)?.getSize() ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCameraIDs(): string[] {
|
public getCameraIDs(): string[] {
|
||||||
|
|||||||
@@ -990,7 +990,7 @@ export class FrigateCameraManagerEngine
|
|||||||
const countSegments = () =>
|
const countSegments = () =>
|
||||||
sum(
|
sum(
|
||||||
cameraIDs.map(
|
cameraIDs.map(
|
||||||
(cameraID) => this._recordingSegmentsCache.getCache(cameraID)?.size() ?? 0,
|
(cameraID) => this._recordingSegmentsCache.getSize(cameraID) ?? 0,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
const segmentsStart = countSegments();
|
const segmentsStart = countSegments();
|
||||||
|
|||||||
@@ -112,15 +112,13 @@ describe('RecordingSegmentsCache', () => {
|
|||||||
expect(cache.hasCoverage('camera-1', range)).toBeFalsy();
|
expect(cache.hasCoverage('camera-1', range)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return internal cache', () => {
|
it('should get size', () => {
|
||||||
cache.add('camera-1', range, segments);
|
cache.add('camera-1', range, segments);
|
||||||
const internalCache = cache.getCache('camera-1');
|
expect(cache.getSize("camera-1")).toBe(3);
|
||||||
expect(internalCache).toBeTruthy();
|
|
||||||
expect(internalCache?.get(range)).toEqual(segments);
|
|
||||||
});
|
});
|
||||||
it('should not return internal cache for wrong camera', () => {
|
it('should not size for other camera', () => {
|
||||||
cache.add('camera-1', range, segments);
|
cache.add('camera-1', range, segments);
|
||||||
expect(cache.getCache('camera-2')).toBeNull();
|
expect(cache.getSize("camera-2")).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return cameraIDs', () => {
|
it('should return cameraIDs', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user