Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): duplicate faces, face insert query failing #13294

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion server/src/repositories/person.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export class PersonRepository implements IPersonRepository {
faceIdsToRemove: string[],
embeddingsToAdd?: FaceSearchEntity[],
): Promise<void> {
const query = this.faceSearchRepository.createQueryBuilder().select('1');
const query = this.faceSearchRepository.createQueryBuilder().select('1').fromDummy();
if (facesToAdd.length > 0) {
const insertCte = this.assetFaceRepository.createQueryBuilder().insert().values(facesToAdd);
query.addCommonTableExpression(insertCte, 'added');
Expand All @@ -296,6 +296,7 @@ export class PersonRepository implements IPersonRepository {
if (embeddingsToAdd?.length) {
const embeddingCte = this.faceSearchRepository.createQueryBuilder().insert().values(embeddingsToAdd).orIgnore();
query.addCommonTableExpression(embeddingCte, 'embeddings');
query.getQuery(); // typeorm mixes up parameters without this
}

await query.execute();
Expand Down
2 changes: 1 addition & 1 deletion server/src/services/person.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export class PersonService extends BaseService {

if (match && !mlFaceIds.delete(match.id)) {
embeddings.push({ faceId: match.id, embedding });
} else {
} else if (!match) {
const faceId = this.cryptoRepository.randomUUID();
facesToAdd.push({
id: faceId,
Expand Down
Loading