From fc2455be808c347967f1950603f532fba0c1b618 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 27 May 2023 16:49:57 -0500 Subject: [PATCH] fix(server): missing metadata extraction job (#2586) * fix(server): missing metadata extraction job * format * fix test * fix test * Added source to upload * fix test * OK! CODE COVERAGE --- server/apps/immich/src/api-v1/asset/asset.core.ts | 2 +- .../apps/immich/src/api-v1/asset/asset.service.spec.ts | 9 +++++++-- server/libs/domain/src/job/job.interface.ts | 1 + server/libs/domain/src/job/job.service.ts | 6 ++++++ server/package.json | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/server/apps/immich/src/api-v1/asset/asset.core.ts b/server/apps/immich/src/api-v1/asset/asset.core.ts index 9732d7e2ac..8b9d868034 100644 --- a/server/apps/immich/src/api-v1/asset/asset.core.ts +++ b/server/apps/immich/src/api-v1/asset/asset.core.ts @@ -43,7 +43,7 @@ export class AssetCore { sidecarPath: sidecarFile?.originalPath || null, }); - await this.jobRepository.queue({ name: JobName.GENERATE_JPEG_THUMBNAIL, data: { id: asset.id } }); + await this.jobRepository.queue({ name: JobName.METADATA_EXTRACTION, data: { id: asset.id, source: 'upload' } }); if (asset.type === AssetType.VIDEO) { await this.jobRepository.queue({ name: JobName.VIDEO_CONVERSION, data: { id: asset.id } }); } diff --git a/server/apps/immich/src/api-v1/asset/asset.service.spec.ts b/server/apps/immich/src/api-v1/asset/asset.service.spec.ts index 39d107dcc3..a97592ead9 100644 --- a/server/apps/immich/src/api-v1/asset/asset.service.spec.ts +++ b/server/apps/immich/src/api-v1/asset/asset.service.spec.ts @@ -328,9 +328,14 @@ describe('AssetService', () => { }); expect(jobMock.queue.mock.calls).toEqual([ - [{ name: JobName.GENERATE_JPEG_THUMBNAIL, data: { id: assetEntityStub.livePhotoMotionAsset.id } }], + [ + { + name: JobName.METADATA_EXTRACTION, + data: { id: assetEntityStub.livePhotoMotionAsset.id, source: 'upload' }, + }, + ], [{ name: JobName.VIDEO_CONVERSION, data: { id: assetEntityStub.livePhotoMotionAsset.id } }], - [{ name: JobName.GENERATE_JPEG_THUMBNAIL, data: { id: assetEntityStub.livePhotoStillAsset.id } }], + [{ name: JobName.METADATA_EXTRACTION, data: { id: assetEntityStub.livePhotoStillAsset.id, source: 'upload' } }], ]); }); }); diff --git a/server/libs/domain/src/job/job.interface.ts b/server/libs/domain/src/job/job.interface.ts index 3a0d2ecc82..bbc966eb9c 100644 --- a/server/libs/domain/src/job/job.interface.ts +++ b/server/libs/domain/src/job/job.interface.ts @@ -19,6 +19,7 @@ export interface IFaceThumbnailJob extends IAssetFaceJob { export interface IEntityJob extends IBaseJob { id: string; + source?: string; } export interface IBulkEntityJob extends IBaseJob { diff --git a/server/libs/domain/src/job/job.service.ts b/server/libs/domain/src/job/job.service.ts index 379ce64592..26c044e7ad 100644 --- a/server/libs/domain/src/job/job.service.ts +++ b/server/libs/domain/src/job/job.service.ts @@ -110,6 +110,12 @@ export class JobService { await this.jobRepository.queue({ name: JobName.STORAGE_TEMPLATE_MIGRATION_SINGLE, data: item.data }); break; + case JobName.STORAGE_TEMPLATE_MIGRATION_SINGLE: + if (item.data.source === 'upload') { + await this.jobRepository.queue({ name: JobName.GENERATE_JPEG_THUMBNAIL, data: item.data }); + } + break; + case JobName.GENERATE_JPEG_THUMBNAIL: { await this.jobRepository.queue({ name: JobName.GENERATE_WEBP_THUMBNAIL, data: item.data }); await this.jobRepository.queue({ name: JobName.CLASSIFY_IMAGE, data: item.data }); diff --git a/server/package.json b/server/package.json index aa36616161..1b9f0a263c 100644 --- a/server/package.json +++ b/server/package.json @@ -141,7 +141,7 @@ "./libs/domain/": { "branches": 80, "functions": 87, - "lines": 94, + "lines": 93.8, "statements": 93 } },