diff --git a/server/src/domain/asset/asset.repository.ts b/server/src/domain/asset/asset.repository.ts index ae8f64e64e..3687ec9cc2 100644 --- a/server/src/domain/asset/asset.repository.ts +++ b/server/src/domain/asset/asset.repository.ts @@ -11,6 +11,7 @@ export interface AssetStatsOptions { export interface AssetSearchOptions { isVisible?: boolean; type?: AssetType; + order?: 'ASC' | 'DESC'; } export interface LivePhotoSearchOptions { diff --git a/server/src/domain/facial-recognition/facial-recognition.services.ts b/server/src/domain/facial-recognition/facial-recognition.services.ts index 69bcec2bdf..90dd4a646f 100644 --- a/server/src/domain/facial-recognition/facial-recognition.services.ts +++ b/server/src/domain/facial-recognition/facial-recognition.services.ts @@ -29,7 +29,7 @@ export class FacialRecognitionService { async handleQueueRecognizeFaces({ force }: IBaseJob) { const assetPagination = usePagination(JOBS_ASSET_PAGINATION_SIZE, (pagination) => { return force - ? this.assetRepository.getAll(pagination) + ? this.assetRepository.getAll(pagination, { order: 'DESC' }) : this.assetRepository.getWithout(pagination, WithoutProperty.FACES); }); diff --git a/server/src/infra/repositories/asset.repository.ts b/server/src/infra/repositories/asset.repository.ts index 09fb3a17ec..82fd0abc31 100644 --- a/server/src/infra/repositories/asset.repository.ts +++ b/server/src/infra/repositories/asset.repository.ts @@ -116,7 +116,7 @@ export class AssetRepository implements IAssetRepository { }, order: { // Ensures correct order when paginating - createdAt: 'ASC', + createdAt: options.order ?? 'ASC', }, }); }