Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Get counts from db

Manav Rathi896de6279473
diff --git a/web/apps/photos/src/services/face/db.ts b/web/apps/photos/src/services/face/db.ts
index 1128395237..85bb322056 100644
--- a/web/apps/photos/src/services/face/db.ts
+++ b/web/apps/photos/src/services/face/db.ts
@@ -197,6 +197,20 @@ export const addFileEntry = async (fileID: number) => {
return tx.done;
};
+/**
+ * Return the count of files that can be, and that have been, indexed.
+ */
+export const indexableAndIndexedCounts = async () => {
+ const db = await faceDB();
+ const tx = db.transaction(["file-status", "face-index"], "readonly");
+ const indexableCount = await tx
+ .objectStore("file-status")
+ .index("isIndexable")
+ .count(IDBKeyRange.only(1));
+ const indexedCount = await tx.objectStore("face-index").count();
+ return { indexableCount, indexedCount };
+};
+
/**
* Return a list of fileIDs that need to be indexed.
*
diff --git a/web/apps/photos/src/services/face/indexer.ts b/web/apps/photos/src/services/face/indexer.ts
index d14b8d484c..a0a400b1e2 100644
--- a/web/apps/photos/src/services/face/indexer.ts
+++ b/web/apps/photos/src/services/face/indexer.ts
@@ -8,7 +8,7 @@ import machineLearningService, {
} from "services/machineLearning/machineLearningService";
import mlWorkManager from "services/machineLearning/mlWorkManager";
import type { EnteFile } from "types/file";
-import { markIndexingFailed } from "./db";
+import { indexableAndIndexedCounts, markIndexingFailed } from "./db";
import type { IndexStatus } from "./db-old";
import { indexFaces } from "./f-index";
import { FaceIndexerWorker } from "./indexer.worker";
@@ -159,7 +159,7 @@ export interface FaceIndexingStatus {
export const faceIndexingStatus = async (): Promise<FaceIndexingStatus> => {
const isSyncing = machineLearningService.isSyncing;
- const [indexableCount, indexedCount] = [0, 0];
+ const { indexableCount, indexedCount } = await indexableAndIndexedCounts();
let phase: FaceIndexingStatus["phase"];
if (indexableCount > 0 && indexableCount > indexedCount) {