mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +00:00
fix(server): duplicate faces, face insert query failing (#13294)
fix duplicate faces, query failing
This commit is contained in:
parent
9d0f03808c
commit
08d428cbce
2 changed files with 3 additions and 2 deletions
|
@ -279,7 +279,7 @@ export class PersonRepository implements IPersonRepository {
|
||||||
faceIdsToRemove: string[],
|
faceIdsToRemove: string[],
|
||||||
embeddingsToAdd?: FaceSearchEntity[],
|
embeddingsToAdd?: FaceSearchEntity[],
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const query = this.faceSearchRepository.createQueryBuilder().select('1');
|
const query = this.faceSearchRepository.createQueryBuilder().select('1').fromDummy();
|
||||||
if (facesToAdd.length > 0) {
|
if (facesToAdd.length > 0) {
|
||||||
const insertCte = this.assetFaceRepository.createQueryBuilder().insert().values(facesToAdd);
|
const insertCte = this.assetFaceRepository.createQueryBuilder().insert().values(facesToAdd);
|
||||||
query.addCommonTableExpression(insertCte, 'added');
|
query.addCommonTableExpression(insertCte, 'added');
|
||||||
|
@ -296,6 +296,7 @@ export class PersonRepository implements IPersonRepository {
|
||||||
if (embeddingsToAdd?.length) {
|
if (embeddingsToAdd?.length) {
|
||||||
const embeddingCte = this.faceSearchRepository.createQueryBuilder().insert().values(embeddingsToAdd).orIgnore();
|
const embeddingCte = this.faceSearchRepository.createQueryBuilder().insert().values(embeddingsToAdd).orIgnore();
|
||||||
query.addCommonTableExpression(embeddingCte, 'embeddings');
|
query.addCommonTableExpression(embeddingCte, 'embeddings');
|
||||||
|
query.getQuery(); // typeorm mixes up parameters without this
|
||||||
}
|
}
|
||||||
|
|
||||||
await query.execute();
|
await query.execute();
|
||||||
|
|
|
@ -325,7 +325,7 @@ export class PersonService extends BaseService {
|
||||||
|
|
||||||
if (match && !mlFaceIds.delete(match.id)) {
|
if (match && !mlFaceIds.delete(match.id)) {
|
||||||
embeddings.push({ faceId: match.id, embedding });
|
embeddings.push({ faceId: match.id, embedding });
|
||||||
} else {
|
} else if (!match) {
|
||||||
const faceId = this.cryptoRepository.randomUUID();
|
const faceId = this.cryptoRepository.randomUUID();
|
||||||
facesToAdd.push({
|
facesToAdd.push({
|
||||||
id: faceId,
|
id: faceId,
|
||||||
|
|
Loading…
Reference in a new issue