Dedup recordings.
This commit is contained in:
@@ -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
@@ -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
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user