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:
@@ -1,11 +1,4 @@
|
||||
import {
|
||||
AssetResponseDto,
|
||||
IAssetRepository,
|
||||
IFaceRepository,
|
||||
IPersonRepository,
|
||||
LoginResponseDto,
|
||||
TimeBucketSize,
|
||||
} from '@app/domain';
|
||||
import { AssetResponseDto, IAssetRepository, IPersonRepository, LoginResponseDto, TimeBucketSize } from '@app/domain';
|
||||
import { AppModule, AssetController } from '@app/immich';
|
||||
import { AssetEntity, AssetType } from '@app/infra/entities';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
@@ -254,8 +247,7 @@ describe(`${AssetController.name} (e2e)`, () => {
|
||||
const personRepository = app.get<IPersonRepository>(IPersonRepository);
|
||||
const person = await personRepository.create({ ownerId: asset1.ownerId, name: 'Test Person' });
|
||||
|
||||
const faceRepository = app.get<IFaceRepository>(IFaceRepository);
|
||||
await faceRepository.create({ assetId: asset1.id, personId: person.id });
|
||||
await personRepository.createFace({ assetId: asset1.id, personId: person.id });
|
||||
|
||||
const { status, body } = await request(server)
|
||||
.put(`/asset/${asset1.id}`)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IFaceRepository, IPersonRepository, LoginResponseDto } from '@app/domain';
|
||||
import { IPersonRepository, LoginResponseDto } from '@app/domain';
|
||||
import { AppModule, PersonController } from '@app/immich';
|
||||
import { PersonEntity } from '@app/infra/entities';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
@@ -14,7 +14,6 @@ describe(`${PersonController.name}`, () => {
|
||||
let loginResponse: LoginResponseDto;
|
||||
let accessToken: string;
|
||||
let personRepository: IPersonRepository;
|
||||
let faceRepository: IFaceRepository;
|
||||
let visiblePerson: PersonEntity;
|
||||
let hiddenPerson: PersonEntity;
|
||||
|
||||
@@ -26,7 +25,6 @@ describe(`${PersonController.name}`, () => {
|
||||
app = await moduleFixture.createNestApplication().init();
|
||||
server = app.getHttpServer();
|
||||
personRepository = app.get<IPersonRepository>(IPersonRepository);
|
||||
faceRepository = app.get<IFaceRepository>(IFaceRepository);
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
@@ -41,7 +39,7 @@ describe(`${PersonController.name}`, () => {
|
||||
name: 'visible_person',
|
||||
thumbnailPath: '/thumbnail/face_asset',
|
||||
});
|
||||
await faceRepository.create({ assetId: faceAsset.id, personId: visiblePerson.id });
|
||||
await personRepository.createFace({ assetId: faceAsset.id, personId: visiblePerson.id });
|
||||
|
||||
hiddenPerson = await personRepository.create({
|
||||
ownerId: loginResponse.userId,
|
||||
@@ -49,7 +47,7 @@ describe(`${PersonController.name}`, () => {
|
||||
isHidden: true,
|
||||
thumbnailPath: '/thumbnail/face_asset',
|
||||
});
|
||||
await faceRepository.create({ assetId: faceAsset.id, personId: hiddenPerson.id });
|
||||
await personRepository.createFace({ assetId: faceAsset.id, personId: hiddenPerson.id });
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import { IFaceRepository } from '@app/domain';
|
||||
|
||||
export const newFaceRepositoryMock = (): jest.Mocked<IFaceRepository> => {
|
||||
return {
|
||||
getAll: jest.fn(),
|
||||
getByIds: jest.fn(),
|
||||
create: jest.fn(),
|
||||
};
|
||||
};
|
||||
@@ -5,7 +5,6 @@ export * from './asset.repository.mock';
|
||||
export * from './audit.repository.mock';
|
||||
export * from './communication.repository.mock';
|
||||
export * from './crypto.repository.mock';
|
||||
export * from './face.repository.mock';
|
||||
export * from './job.repository.mock';
|
||||
export * from './library.repository.mock';
|
||||
export * from './machine-learning.repository.mock';
|
||||
|
||||
@@ -14,9 +14,11 @@ export const newPersonRepositoryMock = (): jest.Mocked<IPersonRepository> => {
|
||||
deleteAll: jest.fn(),
|
||||
delete: jest.fn(),
|
||||
|
||||
getFaceById: jest.fn(),
|
||||
getAllFaces: jest.fn(),
|
||||
getFacesByIds: jest.fn(),
|
||||
getRandomFace: jest.fn(),
|
||||
prepareReassignFaces: jest.fn(),
|
||||
reassignFaces: jest.fn(),
|
||||
createFace: jest.fn(),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user