Update all

This commit is contained in:
Manav Rathi
2024-08-13 20:23:04 +05:30
parent 3097810f2c
commit 113bd9744e
2 changed files with 31 additions and 10 deletions

View File

@@ -419,13 +419,41 @@ export const markIndexingFailed = async (fileID: number) => {
*/
export const faceClusters = async () => {
const db = await mlDB();
return await db.getAll("face-cluster");
return db.getAll("face-cluster");
};
/**
* Return all people present locally.
* Return all person entries (aka "people") present locally.
*/
export const persons = async () => {
const db = await mlDB();
return await db.getAll("person");
return db.getAll("person");
};
/**
* Replace the face clusters stored locally with the given ones.
*
* This function deletes all entries from the person object store, and then
* inserts the given {@link clusters} into it.
*/
export const setFaceClusters = async (clusters: FaceCluster[]) => {
const db = await mlDB();
const tx = db.transaction("face-cluster", "readwrite");
await tx.store.clear();
await Promise.all(clusters.map((cluster) => tx.store.put(cluster)));
return tx.done;
};
/**
* Replace the persons stored locally with the given ones.
*
* This function deletes all entries from the person object store, and then
* inserts the given {@link persons} into it.
*/
export const setPersons = async (persons: Person[]) => {
const db = await mlDB();
const tx = db.transaction("person", "readwrite");
await tx.store.clear();
await Promise.all(persons.map((person) => tx.store.put(person)));
return tx.done;
};

View File

@@ -71,13 +71,6 @@ export const syncPeopleIndex = async () => {
for (const [index, cluster] of clusters.entries()) {
const faces = cluster.map((f) => allFaces[f]).filter((f) => f);
// TODO: take default display face from last leaves of hdbscan clusters
const personFace = faces.reduce((best, face) =>
face.detection.probability > best.detection.probability
? face
: best,
);
await mlIDbStorage.putPerson(person);