From c297a60c852312f102ed5927a1fedbf465408e2f Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Wed, 9 Oct 2024 13:11:17 +0530 Subject: [PATCH] Impl --- web/packages/new/photos/services/ml/index.ts | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.ts index b2b33a26e2..0e6a226f71 100644 --- a/web/packages/new/photos/services/ml/index.ts +++ b/web/packages/new/photos/services/ml/index.ts @@ -734,6 +734,28 @@ export const addPerson = async (name: string, cluster: FaceCluster) => { return mlSync(); }; +/** + * Add a new cluster to an existing named person. + * + * @param cgroup The existing cgroup underlying the person. This is the (remote) + * user entity that will get updated. + * + * @param cluster The new cluster of faces to associate with this person. + */ +export const addClusterToPerson = async ( + cluster: FaceCluster, + cgroup: CGroup, +) => { + const masterKey = await masterKeyFromSession(); + const assigned = cgroup.data.assigned.concat([cluster]); + await updateOrCreateUserEntities( + "cgroup", + [{ ...cgroup, data: { ...cgroup.data, assigned } }], + masterKey, + ); + return mlSync(); +}; + /** * Rename an existing named person. *