Skip to content

Commit

Permalink
fix(server): only queue ml / transcoding jobs after thumbnail generat…
Browse files Browse the repository at this point in the history
…ion on upload (#7516)
  • Loading branch information
mertalev authored Feb 29, 2024
1 parent 11de526 commit dc7a329
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
7 changes: 1 addition & 6 deletions server/src/domain/job/job.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' } },
Expand Down
18 changes: 10 additions & 8 deletions server/src/domain/job/job.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
}
}
}

Expand Down

0 comments on commit dc7a329

Please sign in to comment.