fix(server): duplicate faces bug (#4844)
This commit is contained in:
parent
cf1dfdc776
commit
e671b30aaf
2 changed files with 19 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
|||
import { Colorspace, SystemConfigKey } from '@app/infra/entities';
|
||||
import { AssetFaceEntity, Colorspace, SystemConfigKey } from '@app/infra/entities';
|
||||
import { BadRequestException, NotFoundException } from '@nestjs/common';
|
||||
import {
|
||||
IAccessRepositoryMock,
|
||||
|
@ -449,6 +449,23 @@ describe(PersonService.name, () => {
|
|||
expect(machineLearningMock.detectFaces).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should skip it the asset has already been processed', async () => {
|
||||
assetMock.getByIds.mockResolvedValue([
|
||||
{
|
||||
...assetStub.noResizePath,
|
||||
faces: [
|
||||
{
|
||||
id: 'asset-face-1',
|
||||
assetId: assetStub.noResizePath.id,
|
||||
personId: faceStub.face1.personId,
|
||||
} as AssetFaceEntity,
|
||||
],
|
||||
},
|
||||
]);
|
||||
await sut.handleRecognizeFaces({ id: assetStub.noResizePath.id });
|
||||
expect(machineLearningMock.detectFaces).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should handle no results', async () => {
|
||||
machineLearningMock.detectFaces.mockResolvedValue([]);
|
||||
assetMock.getByIds.mockResolvedValue([assetStub.image]);
|
||||
|
|
|
@ -217,7 +217,7 @@ export class PersonService {
|
|||
}
|
||||
|
||||
const [asset] = await this.assetRepository.getByIds([id]);
|
||||
if (!asset || !asset.resizePath) {
|
||||
if (!asset || !asset.resizePath || asset.faces?.length > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue