mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
refactor(server): merge facial-recognition and person (#4237)
* move facial recognition service into person service * merge face repository and person repository * fix imports
This commit is contained in:
@@ -5,7 +5,6 @@ import {
|
||||
IAuditRepository,
|
||||
ICommunicationRepository,
|
||||
ICryptoRepository,
|
||||
IFaceRepository,
|
||||
IJobRepository,
|
||||
IKeyRepository,
|
||||
ILibraryRepository,
|
||||
@@ -40,7 +39,6 @@ import {
|
||||
AuditRepository,
|
||||
CommunicationRepository,
|
||||
CryptoRepository,
|
||||
FaceRepository,
|
||||
FilesystemProvider,
|
||||
JobRepository,
|
||||
LibraryRepository,
|
||||
@@ -65,7 +63,6 @@ const providers: Provider[] = [
|
||||
{ provide: IAuditRepository, useClass: AuditRepository },
|
||||
{ provide: ICommunicationRepository, useClass: CommunicationRepository },
|
||||
{ provide: ICryptoRepository, useClass: CryptoRepository },
|
||||
{ provide: IFaceRepository, useClass: FaceRepository },
|
||||
{ provide: IJobRepository, useClass: JobRepository },
|
||||
{ provide: ILibraryRepository, useClass: LibraryRepository },
|
||||
{ provide: IKeyRepository, useClass: APIKeyRepository },
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
import { AssetFaceId, IFaceRepository } from '@app/domain';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { AssetFaceEntity } from '../entities/asset-face.entity';
|
||||
|
||||
@Injectable()
|
||||
export class FaceRepository implements IFaceRepository {
|
||||
constructor(@InjectRepository(AssetFaceEntity) private repository: Repository<AssetFaceEntity>) {}
|
||||
|
||||
getAll(): Promise<AssetFaceEntity[]> {
|
||||
return this.repository.find({ relations: { asset: true } });
|
||||
}
|
||||
|
||||
getByIds(ids: AssetFaceId[]): Promise<AssetFaceEntity[]> {
|
||||
return this.repository.find({ where: ids, relations: { asset: true } });
|
||||
}
|
||||
|
||||
create(entity: Partial<AssetFaceEntity>): Promise<AssetFaceEntity> {
|
||||
return this.repository.save(entity);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ export * from './asset.repository';
|
||||
export * from './audit.repository';
|
||||
export * from './communication.repository';
|
||||
export * from './crypto.repository';
|
||||
export * from './face.repository';
|
||||
export * from './filesystem.provider';
|
||||
export * from './job.repository';
|
||||
export * from './library.repository';
|
||||
|
||||
@@ -50,6 +50,10 @@ export class PersonRepository implements IPersonRepository {
|
||||
return people.length;
|
||||
}
|
||||
|
||||
getAllFaces(): Promise<AssetFaceEntity[]> {
|
||||
return this.assetFaceRepository.find({ relations: { asset: true } });
|
||||
}
|
||||
|
||||
getAll(): Promise<PersonEntity[]> {
|
||||
return this.personRepository.find();
|
||||
}
|
||||
@@ -117,13 +121,17 @@ export class PersonRepository implements IPersonRepository {
|
||||
return this.personRepository.save(entity);
|
||||
}
|
||||
|
||||
createFace(entity: Partial<AssetFaceEntity>): Promise<AssetFaceEntity> {
|
||||
return this.assetFaceRepository.save(entity);
|
||||
}
|
||||
|
||||
async update(entity: Partial<PersonEntity>): Promise<PersonEntity> {
|
||||
const { id } = await this.personRepository.save(entity);
|
||||
return this.personRepository.findOneByOrFail({ id });
|
||||
}
|
||||
|
||||
async getFaceById({ personId, assetId }: AssetFaceId): Promise<AssetFaceEntity | null> {
|
||||
return this.assetFaceRepository.findOneBy({ assetId, personId });
|
||||
async getFacesByIds(ids: AssetFaceId[]): Promise<AssetFaceEntity[]> {
|
||||
return this.assetFaceRepository.find({ where: ids, relations: { asset: true } });
|
||||
}
|
||||
|
||||
async getRandomFace(personId: string): Promise<AssetFaceEntity | null> {
|
||||
|
||||
Reference in New Issue
Block a user