feat(server): don't re-run face recognition on assets without any faces (#4854)
* Add AssetJobStatus * fentity * Add jobStatus field to AssetEntity * Fix the migration doc paths * Filter on facesRecognizedAt * Set facesRecognizedAt field * Test for facesRecognizedAt * Done testing * Adjust FK properties * Add tests for WithoutProperty.FACES * chore: non-nullable --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
committed by
GitHub
parent
75c065c83a
commit
986bbfa831
@@ -20,7 +20,7 @@ import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { DateTime } from 'luxon';
|
||||
import { And, FindOptionsRelations, FindOptionsWhere, In, IsNull, LessThan, Not, Repository } from 'typeorm';
|
||||
import { AssetEntity, AssetType, ExifEntity } from '../entities';
|
||||
import { AssetEntity, AssetJobStatusEntity, AssetType, ExifEntity } from '../entities';
|
||||
import OptionalBetween from '../utils/optional-between.util';
|
||||
import { paginate } from '../utils/pagination.util';
|
||||
|
||||
@@ -39,12 +39,17 @@ export class AssetRepository implements IAssetRepository {
|
||||
constructor(
|
||||
@InjectRepository(AssetEntity) private repository: Repository<AssetEntity>,
|
||||
@InjectRepository(ExifEntity) private exifRepository: Repository<ExifEntity>,
|
||||
@InjectRepository(AssetJobStatusEntity) private jobStatusRepository: Repository<AssetJobStatusEntity>,
|
||||
) {}
|
||||
|
||||
async upsertExif(exif: Partial<ExifEntity>): Promise<void> {
|
||||
await this.exifRepository.upsert(exif, { conflictPaths: ['assetId'] });
|
||||
}
|
||||
|
||||
async upsertJobStatus(jobStatus: Partial<AssetJobStatusEntity>): Promise<void> {
|
||||
await this.jobStatusRepository.upsert(jobStatus, { conflictPaths: ['assetId'] });
|
||||
}
|
||||
|
||||
create(asset: AssetCreate): Promise<AssetEntity> {
|
||||
return this.repository.save(asset);
|
||||
}
|
||||
@@ -323,6 +328,7 @@ export class AssetRepository implements IAssetRepository {
|
||||
case WithoutProperty.FACES:
|
||||
relations = {
|
||||
faces: true,
|
||||
jobStatus: true,
|
||||
};
|
||||
where = {
|
||||
resizePath: Not(IsNull()),
|
||||
@@ -331,6 +337,9 @@ export class AssetRepository implements IAssetRepository {
|
||||
assetId: IsNull(),
|
||||
personId: IsNull(),
|
||||
},
|
||||
jobStatus: {
|
||||
facesRecognizedAt: IsNull(),
|
||||
},
|
||||
};
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user