Dedup recordings.

This commit is contained in:
Dermot Duffy
2023-01-24 19:36:54 -08:00
parent 54f63d0cf3
commit 9c1ea3b922
3 changed files with 17 additions and 4 deletions
+2 -2
View File
@@ -108,8 +108,8 @@ export class FrigateCameraManagerEngine implements CameraManagerEngine {
return {
type: QueryType.Event,
cameraID: cameraID,
...(cameraConfig.frigate.label && { label: cameraConfig.frigate.label }),
...(cameraConfig.frigate.zone && { zone: cameraConfig.frigate.zone }),
...(cameraConfig.frigate.label && { what: cameraConfig.frigate.label }),
...(cameraConfig.frigate.zone && { where: cameraConfig.frigate.zone }),
...query,
};
}
+14 -1
View File
@@ -25,6 +25,7 @@ import { ViewMedia } from '../view/media.js';
import { MediaQueriesResults } from '../view/media-queries-results';
import { MemoryRequestCache } from './cache.js';
import { MediaQueries } from '../view/media-queries.js';
import uniqBy from 'lodash-es/uniqBy';
export class QueryClassifier {
public static isEventQuery(query: DataQuery | PartialDataQuery): query is EventQuery {
@@ -204,7 +205,19 @@ export class CameraManager {
}
return new MediaQueriesResults(
orderBy(mediaArray, (media) => media.getStartTime(), 'desc'),
orderBy(
// Ensure uniqueness by the ID (if specified), otherwise all elements
// are assumed to be unique.
uniqBy(
mediaArray,
(media) => media.getID(this._cameras.get(media.getCameraID())) ?? media,
),
// Sort all items leading with the most recent.
(media) => media.getStartTime(),
'desc',
),
// Select the first (most-recent) item.
mediaArray.length ? 0 : null,
);
+1 -1
View File
@@ -1,8 +1,8 @@
// Medium:
// - TODO: Add garbage collecting of segments not present in the recording summaries anymore.
// - TODO: Do I need to dedup recordings? (i.e. multiple zones on same camera may need to be dedup'd somewhere before returning the view). The media getID() call may be useful for this.
// - TODO: Move frigate specific view-media under the camera manager.
// - TODO: ts-prune https://camchenry.com/blog/deleting-dead-code-in-typescript
// - TODO: Engine should not need cameraConfig to favorite since it already has cameras.
// Hard:
// - TODO: Implement dragging the timeline seeking forward in both Frigate recordings & events.