From ddddc09226b378bf00541c04e83564dc78415b06 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Thu, 30 May 2024 10:02:57 +0530 Subject: [PATCH] New --- web/apps/photos/src/services/face/indexer.ts | 41 +++++++++++++++++++ web/apps/photos/src/services/searchService.ts | 5 ++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/web/apps/photos/src/services/face/indexer.ts b/web/apps/photos/src/services/face/indexer.ts index 75330d86ed..d9ce6066a7 100644 --- a/web/apps/photos/src/services/face/indexer.ts +++ b/web/apps/photos/src/services/face/indexer.ts @@ -5,6 +5,7 @@ import { type Remote } from "comlink"; import mlWorkManager from "services/machineLearning/mlWorkManager"; import type { EnteFile } from "types/file"; import { markIndexingFailed } from "./db"; +import type { IndexStatus } from "./db-old"; import { indexFaces } from "./f-index"; import { FaceIndexerWorker } from "./indexer.worker"; @@ -129,3 +130,43 @@ const createFaceIndexerComlinkWorker = () => "face-indexer", new Worker(new URL("indexer.worker.ts", import.meta.url)), ); + +export interface FaceIndexingStatus { + /** + * Which phase we are in within the indexing pipeline when viewed across the + * user's entire library: + * + * - "scheduled": There are files we know of that have not been indexed. + * + * - "indexing": The face indexer is currently running. + * + * - "clustering": All files we know of have been indexed, and we are now + * clustering the faces that were found. + * + * - "done": Face indexing and clustering is complete for the user's + * library. + */ + phase: "scheduled" | "indexing" | "clustering" | "done"; + outOfSyncFilesExists: boolean; + nSyncedFiles: number; + nTotalFiles: number; + localFilesSynced: boolean; + peopleIndexSynced: boolean; +} + +export const convertToNewInterface = (indexStatus: IndexStatus) => { + let phase: string; + if (!indexStatus.localFilesSynced) { + phase = "scheduled"; + } else if (indexStatus.outOfSyncFilesExists) { + phase = "indexing"; + } else if (!indexStatus.peopleIndexSynced) { + phase = "clustering"; + } else { + phase = "done"; + } + return { + ...indexStatus, + phase, + }; +}; diff --git a/web/apps/photos/src/services/searchService.ts b/web/apps/photos/src/services/searchService.ts index b48778f690..472441ba66 100644 --- a/web/apps/photos/src/services/searchService.ts +++ b/web/apps/photos/src/services/searchService.ts @@ -22,6 +22,7 @@ import { getFormattedDate } from "utils/search"; import { clipService, computeClipMatchScore } from "./clip-service"; import { localCLIPEmbeddings } from "./embeddingService"; import { getLatestEntities } from "./entityService"; +import { convertToNewInterface } from "./face/indexer"; import locationSearchService, { City } from "./locationSearchService"; const DIGITS = new Set(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]); @@ -175,7 +176,9 @@ export async function getAllPeopleSuggestion(): Promise> { export async function getIndexStatusSuggestion(): Promise { try { - const indexStatus = await mlIDbStorage.getIndexStatus(defaultMLVersion); + const indexStatus0 = + await mlIDbStorage.getIndexStatus(defaultMLVersion); + const indexStatus = convertToNewInterface(indexStatus0); let label; if (!indexStatus.localFilesSynced) {