chore(server): remove unused filename (#2517)

This commit is contained in:
Jason Rasmussen 2023-05-22 11:26:56 -04:00 committed by GitHub
parent 74353193f8
commit eefe5266a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 17 additions and 45 deletions

View File

@ -41,7 +41,7 @@ export class AssetCore {
faces: [],
});
await this.jobRepository.queue({ name: JobName.ASSET_UPLOADED, data: { asset, fileName: file.originalName } });
await this.jobRepository.queue({ name: JobName.ASSET_UPLOADED, data: { asset } });
return asset;
}

View File

@ -328,18 +328,8 @@ describe('AssetService', () => {
});
expect(jobMock.queue.mock.calls).toEqual([
[
{
name: JobName.ASSET_UPLOADED,
data: { asset: assetEntityStub.livePhotoMotionAsset, fileName: 'asset_1.mp4' },
},
],
[
{
name: JobName.ASSET_UPLOADED,
data: { asset: assetEntityStub.livePhotoStillAsset, fileName: 'asset_1.jpeg' },
},
],
[{ name: JobName.ASSET_UPLOADED, data: { asset: assetEntityStub.livePhotoMotionAsset } }],
[{ name: JobName.ASSET_UPLOADED, data: { asset: assetEntityStub.livePhotoStillAsset } }],
]);
});
});

View File

@ -3,7 +3,6 @@ import {
FacialRecognitionService,
IAssetFaceJob,
IAssetJob,
IAssetUploadedJob,
IBaseJob,
IBulkEntityJob,
IDeleteFilesJob,
@ -34,7 +33,7 @@ export class BackgroundTaskProcessor {
) {}
@Process(JobName.ASSET_UPLOADED)
async onAssetUpload(job: Job<IAssetUploadedJob>) {
async onAssetUpload(job: Job<IAssetJob>) {
await this.assetService.handleAssetUpload(job.data);
}

View File

@ -1,7 +1,7 @@
import {
AssetCore,
IAssetJob,
IAssetRepository,
IAssetUploadedJob,
IBaseJob,
IGeocodingRepository,
IJobRepository,
@ -79,9 +79,8 @@ export class MetadataExtractionProcessor {
: await this.assetRepository.getWithout(WithoutProperty.EXIF);
for (const asset of assets) {
const fileName = asset.originalFileName;
const name = asset.type === AssetType.VIDEO ? JobName.EXTRACT_VIDEO_METADATA : JobName.EXIF_EXTRACTION;
await this.jobRepository.queue({ name, data: { asset, fileName } });
await this.jobRepository.queue({ name, data: { asset } });
}
} catch (error: any) {
this.logger.error(`Unable to queue metadata extraction`, error?.stack);
@ -89,7 +88,7 @@ export class MetadataExtractionProcessor {
}
@Process(JobName.EXIF_EXTRACTION)
async extractExifInfo(job: Job<IAssetUploadedJob>) {
async extractExifInfo(job: Job<IAssetJob>) {
let asset = job.data.asset;
try {
@ -194,7 +193,7 @@ export class MetadataExtractionProcessor {
}
@Process({ name: JobName.EXTRACT_VIDEO_METADATA, concurrency: 2 })
async extractVideoMetadata(job: Job<IAssetUploadedJob>) {
async extractVideoMetadata(job: Job<IAssetJob>) {
let asset = job.data.asset;
if (!asset.isVisible) {

View File

@ -20,7 +20,7 @@ describe(AssetService.name, () => {
describe(`handle asset upload`, () => {
it('should process an uploaded video', async () => {
const data = { asset: { type: AssetType.VIDEO } as AssetEntity, fileName: 'video.mp4' };
const data = { asset: { type: AssetType.VIDEO } as AssetEntity };
await expect(sut.handleAssetUpload(data)).resolves.toBeUndefined();
@ -33,7 +33,7 @@ describe(AssetService.name, () => {
});
it('should process an uploaded image', async () => {
const data = { asset: { type: AssetType.IMAGE } as AssetEntity, fileName: 'image.jpg' };
const data = { asset: { type: AssetType.IMAGE } as AssetEntity };
await sut.handleAssetUpload(data);

View File

@ -1,7 +1,7 @@
import { AssetEntity, AssetType } from '@app/infra/entities';
import { Inject } from '@nestjs/common';
import { AuthUserDto } from '../auth';
import { IAssetUploadedJob, IJobRepository, JobName } from '../job';
import { IAssetJob, IJobRepository, JobName } from '../job';
import { AssetCore } from './asset.core';
import { IAssetRepository } from './asset.repository';
import { MapMarkerDto } from './dto/map-marker.dto';
@ -17,7 +17,7 @@ export class AssetService {
this.assetCore = new AssetCore(assetRepository, jobRepository);
}
async handleAssetUpload(data: IAssetUploadedJob) {
async handleAssetUpload(data: IAssetJob) {
await this.jobRepository.queue({ name: JobName.GENERATE_JPEG_THUMBNAIL, data });
if (data.asset.type == AssetType.VIDEO) {

View File

@ -30,11 +30,6 @@ export interface IBulkEntityJob extends IBaseJob {
ids: string[];
}
export interface IAssetUploadedJob extends IBaseJob {
asset: AssetEntity;
fileName: string;
}
export interface IDeleteFilesJob extends IBaseJob {
files: Array<string | null | undefined>;
}

View File

@ -2,7 +2,6 @@ import { JobName, QueueName } from './job.constants';
import {
IAssetFaceJob,
IAssetJob,
IAssetUploadedJob,
IBaseJob,
IBulkEntityJob,
IDeleteFilesJob,
@ -26,7 +25,7 @@ export interface QueueStatus {
export type JobItem =
// Asset Upload
| { name: JobName.ASSET_UPLOADED; data: IAssetUploadedJob }
| { name: JobName.ASSET_UPLOADED; data: IAssetJob }
// Transcoding
| { name: JobName.QUEUE_VIDEO_CONVERSION; data: IBaseJob }
@ -48,8 +47,8 @@ export type JobItem =
// Metadata Extraction
| { name: JobName.QUEUE_METADATA_EXTRACTION; data: IBaseJob }
| { name: JobName.EXIF_EXTRACTION; data: IAssetUploadedJob }
| { name: JobName.EXTRACT_VIDEO_METADATA; data: IAssetUploadedJob }
| { name: JobName.EXIF_EXTRACTION; data: IAssetJob }
| { name: JobName.EXTRACT_VIDEO_METADATA; data: IAssetJob }
// Object Tagging
| { name: JobName.QUEUE_OBJECT_TAGGING; data: IBaseJob }

View File

@ -1,14 +1,4 @@
import {
IAssetJob,
IAssetUploadedJob,
IBaseJob,
IJobRepository,
JobCounts,
JobItem,
JobName,
QueueName,
QueueStatus,
} from '@app/domain';
import { IAssetJob, IBaseJob, IJobRepository, JobCounts, JobItem, JobName, QueueName, QueueStatus } from '@app/domain';
import { InjectQueue } from '@nestjs/bull';
import { Logger } from '@nestjs/common';
import { Queue, type JobCounts as BullJobCounts } from 'bull';
@ -31,7 +21,7 @@ export class JobRepository implements IJobRepository {
@InjectQueue(QueueName.BACKGROUND_TASK) private backgroundTask: Queue,
@InjectQueue(QueueName.OBJECT_TAGGING) private objectTagging: Queue<IAssetJob | IBaseJob>,
@InjectQueue(QueueName.CLIP_ENCODING) private clipEmbedding: Queue<IAssetJob | IBaseJob>,
@InjectQueue(QueueName.METADATA_EXTRACTION) private metadataExtraction: Queue<IAssetUploadedJob | IBaseJob>,
@InjectQueue(QueueName.METADATA_EXTRACTION) private metadataExtraction: Queue<IAssetJob | IBaseJob>,
@InjectQueue(QueueName.RECOGNIZE_FACES) private recognizeFaces: Queue<IAssetJob | IBaseJob>,
@InjectQueue(QueueName.STORAGE_TEMPLATE_MIGRATION) private storageTemplateMigration: Queue,
@InjectQueue(QueueName.THUMBNAIL_GENERATION) private generateThumbnail: Queue,