mirror of
https://github.com/immich-app/immich.git
synced 2025-12-24 01:11:32 +03:00
refactor: job vs queue naming (#23902)
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
import { Body, Controller, Get, HttpCode, HttpStatus, Param, Post, Put } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { Endpoint, HistoryBuilder } from 'src/decorators';
|
||||
import { AllJobStatusResponseDto, JobCommandDto, JobCreateDto, JobIdParamDto, JobStatusDto } from 'src/dtos/job.dto';
|
||||
import { JobCreateDto } from 'src/dtos/job.dto';
|
||||
import { QueueCommandDto, QueueNameParamDto, QueueResponseDto, QueuesResponseDto } from 'src/dtos/queue.dto';
|
||||
import { ApiTag, Permission } from 'src/enum';
|
||||
import { Authenticated } from 'src/middleware/auth.guard';
|
||||
import { JobService } from 'src/services/job.service';
|
||||
import { QueueService } from 'src/services/queue.service';
|
||||
|
||||
@ApiTags(ApiTag.Jobs)
|
||||
@Controller('jobs')
|
||||
export class JobController {
|
||||
constructor(private service: JobService) {}
|
||||
constructor(
|
||||
private service: JobService,
|
||||
private queueService: QueueService,
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
@Authenticated({ permission: Permission.JobRead, admin: true })
|
||||
@@ -18,8 +23,8 @@ export class JobController {
|
||||
description: 'Retrieve the counts of the current queue, as well as the current status.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
getAllJobsStatus(): Promise<AllJobStatusResponseDto> {
|
||||
return this.service.getAllJobsStatus();
|
||||
getQueuesLegacy(): Promise<QueuesResponseDto> {
|
||||
return this.queueService.getAll();
|
||||
}
|
||||
|
||||
@Post()
|
||||
@@ -35,7 +40,7 @@ export class JobController {
|
||||
return this.service.create(dto);
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
@Put(':name')
|
||||
@Authenticated({ permission: Permission.JobCreate, admin: true })
|
||||
@Endpoint({
|
||||
summary: 'Run jobs',
|
||||
@@ -43,7 +48,7 @@ export class JobController {
|
||||
'Queue all assets for a specific job type. Defaults to only queueing assets that have not yet been processed, but the force command can be used to re-process all assets.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
sendJobCommand(@Param() { id }: JobIdParamDto, @Body() dto: JobCommandDto): Promise<JobStatusDto> {
|
||||
return this.service.handleCommand(id, dto);
|
||||
runQueueCommandLegacy(@Param() { name }: QueueNameParamDto, @Body() dto: QueueCommandDto): Promise<QueueResponseDto> {
|
||||
return this.queueService.runCommand(name, dto);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user