mirror of
https://github.com/immich-app/immich.git
synced 2026-01-18 15:55:56 -08:00
@@ -1,9 +1,10 @@
|
||||
import { BadRequestException, Inject } from '@nestjs/common';
|
||||
import { BadRequestException, Inject, Optional } from '@nestjs/common';
|
||||
import sanitize from 'sanitize-filename';
|
||||
import { SystemConfig } from 'src/config';
|
||||
import { SALT_ROUNDS } from 'src/constants';
|
||||
import { IWorker, SALT_ROUNDS } from 'src/constants';
|
||||
import { StorageCore } from 'src/cores/storage.core';
|
||||
import { UserEntity } from 'src/entities/user.entity';
|
||||
import { ImmichWorker } from 'src/enum';
|
||||
import { IAccessRepository } from 'src/interfaces/access.interface';
|
||||
import { IActivityRepository } from 'src/interfaces/activity.interface';
|
||||
import { IAlbumUserRepository } from 'src/interfaces/album-user.interface';
|
||||
@@ -49,6 +50,7 @@ export class BaseService {
|
||||
protected storageCore: StorageCore;
|
||||
|
||||
constructor(
|
||||
@Inject(IWorker) @Optional() protected worker: ImmichWorker | undefined,
|
||||
@Inject(ILoggerRepository) protected logger: ILoggerRepository,
|
||||
@Inject(IAccessRepository) protected accessRepository: IAccessRepository,
|
||||
@Inject(IActivityRepository) protected activityRepository: IActivityRepository,
|
||||
|
||||
@@ -18,7 +18,9 @@ describe(JobService.name, () => {
|
||||
let telemetryMock: Mocked<ITelemetryRepository>;
|
||||
|
||||
beforeEach(() => {
|
||||
({ sut, assetMock, jobMock, loggerMock, telemetryMock } = newTestService(JobService));
|
||||
({ sut, assetMock, jobMock, loggerMock, telemetryMock } = newTestService(JobService, {
|
||||
worker: ImmichWorker.MICROSERVICES,
|
||||
}));
|
||||
});
|
||||
|
||||
it('should work', () => {
|
||||
@@ -27,7 +29,6 @@ describe(JobService.name, () => {
|
||||
|
||||
describe('onConfigUpdate', () => {
|
||||
it('should update concurrency', () => {
|
||||
sut.onBootstrap(ImmichWorker.MICROSERVICES);
|
||||
sut.onConfigUpdate({ oldConfig: defaults, newConfig: defaults });
|
||||
|
||||
expect(jobMock.setConcurrency).toHaveBeenCalledTimes(15);
|
||||
|
||||
@@ -38,16 +38,9 @@ const asJobItem = (dto: JobCreateDto): JobItem => {
|
||||
|
||||
@Injectable()
|
||||
export class JobService extends BaseService {
|
||||
private isMicroservices = false;
|
||||
|
||||
@OnEvent({ name: 'app.bootstrap' })
|
||||
onBootstrap(app: ArgOf<'app.bootstrap'>) {
|
||||
this.isMicroservices = app === ImmichWorker.MICROSERVICES;
|
||||
}
|
||||
|
||||
@OnEvent({ name: 'config.update', server: true })
|
||||
onConfigUpdate({ newConfig: config }: ArgOf<'config.update'>) {
|
||||
if (!this.isMicroservices) {
|
||||
if (this.worker !== ImmichWorker.MICROSERVICES) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user