From 1017a1ee82207175817806c6be6c3ce891901d64 Mon Sep 17 00:00:00 2001 From: mertalev <101130780+mertalev@users.noreply.github.com> Date: Wed, 28 Feb 2024 21:51:48 -0500 Subject: [PATCH] don't queue intensive jobs if not from upload --- server/src/domain/job/job.service.spec.ts | 7 +------ server/src/domain/job/job.service.ts | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/server/src/domain/job/job.service.spec.ts b/server/src/domain/job/job.service.spec.ts index 58cda724f814c..5a4d26b3c4816 100644 --- a/server/src/domain/job/job.service.spec.ts +++ b/server/src/domain/job/job.service.spec.ts @@ -286,12 +286,7 @@ describe(JobService.name, () => { }, { item: { name: JobName.GENERATE_JPEG_THUMBNAIL, data: { id: 'asset-1' } }, - jobs: [ - JobName.GENERATE_WEBP_THUMBNAIL, - JobName.GENERATE_THUMBHASH_THUMBNAIL, - JobName.SMART_SEARCH, - JobName.FACE_DETECTION, - ], + jobs: [JobName.GENERATE_WEBP_THUMBNAIL, JobName.GENERATE_THUMBHASH_THUMBNAIL], }, { item: { name: JobName.GENERATE_JPEG_THUMBNAIL, data: { id: 'asset-1', source: 'upload' } }, diff --git a/server/src/domain/job/job.service.ts b/server/src/domain/job/job.service.ts index 25055f1f317c9..1010185b2ca54 100644 --- a/server/src/domain/job/job.service.ts +++ b/server/src/domain/job/job.service.ts @@ -248,16 +248,18 @@ export class JobService { const jobs: JobItem[] = [ { name: JobName.GENERATE_WEBP_THUMBNAIL, data: item.data }, { name: JobName.GENERATE_THUMBHASH_THUMBNAIL, data: item.data }, - { name: JobName.SMART_SEARCH, data: item.data }, - { name: JobName.FACE_DETECTION, data: item.data }, ]; - const [asset] = await this.assetRepository.getByIds([item.data.id]); - if (asset) { - if (asset.type === AssetType.VIDEO) { - jobs.push({ name: JobName.VIDEO_CONVERSION, data: item.data }); - } else if (asset.livePhotoVideoId) { - jobs.push({ name: JobName.VIDEO_CONVERSION, data: { id: asset.livePhotoVideoId } }); + if (item.data.source === 'upload') { + jobs.push({ name: JobName.SMART_SEARCH, data: item.data }, { name: JobName.FACE_DETECTION, data: item.data }); + + const [asset] = await this.assetRepository.getByIds([item.data.id]); + if (asset) { + if (asset.type === AssetType.VIDEO) { + jobs.push({ name: JobName.VIDEO_CONVERSION, data: item.data }); + } else if (asset.livePhotoVideoId) { + jobs.push({ name: JobName.VIDEO_CONVERSION, data: { id: asset.livePhotoVideoId } }); + } } }