diff --git a/web/apps/photos/src/services/face/indexer.ts b/web/apps/photos/src/services/face/indexer.ts index 1b1a01d6ed..c2188a3921 100644 --- a/web/apps/photos/src/services/face/indexer.ts +++ b/web/apps/photos/src/services/face/indexer.ts @@ -2,6 +2,8 @@ import log from "@/next/log"; import { ComlinkWorker } from "@/next/worker/comlink-worker"; import { wait } from "@/utils/promise"; import { type Remote } from "comlink"; +import mlIDbStorage from "services/face/db-old"; +import { defaultMLVersion } from "services/machineLearning/machineLearningService"; import mlWorkManager from "services/machineLearning/mlWorkManager"; import type { EnteFile } from "types/file"; import { markIndexingFailed } from "./db"; @@ -153,8 +155,14 @@ export interface FaceIndexingStatus { nTotalFiles: number; } +export const faceIndexingStatus = async (): Promise => { + const indexStatus0 = await mlIDbStorage.getIndexStatus(defaultMLVersion); + const indexStatus = convertToNewInterface(indexStatus0); + return indexStatus; +}; + export const convertToNewInterface = (indexStatus: IndexStatus) => { - let phase: string; + let phase: FaceIndexingStatus["phase"]; if (!indexStatus.localFilesSynced) { phase = "scheduled"; } else if (indexStatus.outOfSyncFilesExists) { diff --git a/web/apps/photos/src/services/searchService.ts b/web/apps/photos/src/services/searchService.ts index 159bd7525c..ded48069f3 100644 --- a/web/apps/photos/src/services/searchService.ts +++ b/web/apps/photos/src/services/searchService.ts @@ -4,7 +4,6 @@ import * as chrono from "chrono-node"; import { t } from "i18next"; import mlIDbStorage from "services/face/db-old"; import type { Person } from "services/face/people"; -import { defaultMLVersion } from "services/machineLearning/machineLearningService"; import { Collection } from "types/collection"; import { EntityType, LocationTag, LocationTagData } from "types/entity"; import { EnteFile } from "types/file"; @@ -22,7 +21,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 { faceIndexingStatus } from "./face/indexer"; import locationSearchService, { City } from "./locationSearchService"; const DIGITS = new Set(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]); @@ -176,9 +175,7 @@ export async function getAllPeopleSuggestion(): Promise> { export async function getIndexStatusSuggestion(): Promise { try { - const indexStatus0 = - await mlIDbStorage.getIndexStatus(defaultMLVersion); - const indexStatus = convertToNewInterface(indexStatus0); + const indexStatus = await faceIndexingStatus(); let label: string; switch (indexStatus.phase) { diff --git a/web/apps/photos/src/types/search/index.ts b/web/apps/photos/src/types/search/index.ts index 3f3de9b460..adeb03d3aa 100644 --- a/web/apps/photos/src/types/search/index.ts +++ b/web/apps/photos/src/types/search/index.ts @@ -1,5 +1,5 @@ import { FILE_TYPE } from "@/media/file-type"; -import { IndexStatus } from "services/face/db-old"; +import type { FaceIndexingStatus } from "services/face/indexer"; import type { Person } from "services/face/people"; import { City } from "services/locationSearchService"; import { LocationTagData } from "types/entity"; @@ -31,7 +31,7 @@ export interface Suggestion { | DateValue | number[] | Person - | IndexStatus + | FaceIndexingStatus | LocationTagData | City | FILE_TYPE