mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor(server): send job command (#2777)
* refactor: send job command * chore: open api
This commit is contained in:
parent
f04e47803c
commit
fde410e2ac
12 changed files with 49 additions and 44 deletions
|
|
@ -6,5 +6,5 @@ export class JobIdDto {
|
|||
@IsNotEmpty()
|
||||
@IsEnum(QueueName)
|
||||
@ApiProperty({ type: String, enum: QueueName, enumName: 'JobName' })
|
||||
jobId!: QueueName;
|
||||
id!: QueueName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,22 +23,28 @@ export class JobService {
|
|||
this.configCore = new SystemConfigCore(configRepository);
|
||||
}
|
||||
|
||||
handleCommand(queueName: QueueName, dto: JobCommandDto): Promise<void> {
|
||||
async handleCommand(queueName: QueueName, dto: JobCommandDto): Promise<JobStatusDto> {
|
||||
this.logger.debug(`Handling command: queue=${queueName},force=${dto.force}`);
|
||||
|
||||
switch (dto.command) {
|
||||
case JobCommand.START:
|
||||
return this.start(queueName, dto);
|
||||
await this.start(queueName, dto);
|
||||
break;
|
||||
|
||||
case JobCommand.PAUSE:
|
||||
return this.jobRepository.pause(queueName);
|
||||
await this.jobRepository.pause(queueName);
|
||||
break;
|
||||
|
||||
case JobCommand.RESUME:
|
||||
return this.jobRepository.resume(queueName);
|
||||
await this.jobRepository.resume(queueName);
|
||||
break;
|
||||
|
||||
case JobCommand.EMPTY:
|
||||
return this.jobRepository.empty(queueName);
|
||||
await this.jobRepository.empty(queueName);
|
||||
break;
|
||||
}
|
||||
|
||||
return this.getJobStatus(queueName);
|
||||
}
|
||||
|
||||
async getJobStatus(queueName: QueueName): Promise<JobStatusDto> {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import { MemoryLaneResponseDto } from '@app/domain/asset/response-dto/memory-lan
|
|||
export class AssetController {
|
||||
constructor(private service: AssetService) {}
|
||||
|
||||
@Get('/map-marker')
|
||||
@Get('map-marker')
|
||||
getMapMarkers(@GetAuthUser() authUser: AuthUserDto, @Query() options: MapMarkerDto): Promise<MapMarkerResponseDto[]> {
|
||||
return this.service.getMapMarkers(authUser, options);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import { UUIDParamDto } from './dto/uuid-param.dto';
|
|||
@Authenticated()
|
||||
@UseValidation()
|
||||
export class AuthController {
|
||||
constructor(private readonly service: AuthService) {}
|
||||
constructor(private service: AuthService) {}
|
||||
|
||||
@PublicRoute()
|
||||
@Post('login')
|
||||
|
|
|
|||
|
|
@ -16,9 +16,8 @@ export class JobController {
|
|||
return this.service.getAllJobsStatus();
|
||||
}
|
||||
|
||||
@Put('/:jobId')
|
||||
async sendJobCommand(@Param() { jobId }: JobIdDto, @Body() dto: JobCommandDto): Promise<JobStatusDto> {
|
||||
await this.service.handleCommand(jobId, dto);
|
||||
return this.service.getJobStatus(jobId);
|
||||
@Put(':id')
|
||||
sendJobCommand(@Param() { id }: JobIdDto, @Body() dto: JobCommandDto): Promise<JobStatusDto> {
|
||||
return this.service.handleCommand(id, dto);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue