feat(web): clear failed jobs (#5423)

* add clear failed jobs button

* refactor: clean up code

* chore: open api

---------

Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
Clement Ong
2023-12-05 10:07:20 +08:00
committed by GitHub
parent 933c24ea6f
commit 982183600d
13 changed files with 55 additions and 9 deletions
+1
View File
@@ -18,6 +18,7 @@ export enum JobCommand {
PAUSE = 'pause',
RESUME = 'resume',
EMPTY = 'empty',
CLEAR_FAILED = 'clear-failed',
}
export enum JobName {
+6
View File
@@ -10,6 +10,7 @@ import {
ISystemConfigRepository,
JobHandler,
JobItem,
QueueCleanType,
} from '../repositories';
import { FeatureFlag, SystemConfigCore } from '../system-config/system-config.core';
import { JobCommand, JobName, QueueName } from './job.constants';
@@ -49,6 +50,11 @@ export class JobService {
case JobCommand.EMPTY:
await this.jobRepository.empty(queueName);
break;
case JobCommand.CLEAR_FAILED:
const failedJobs = await this.jobRepository.clear(queueName, QueueCleanType.FAILED);
this.logger.debug(`Cleared failed jobs: ${failedJobs}`);
break;
}
return this.getJobStatus(queueName);
@@ -26,6 +26,10 @@ export interface QueueStatus {
isPaused: boolean;
}
export enum QueueCleanType {
FAILED = 'failed',
}
export type JobItem =
// Transcoding
| { name: JobName.QUEUE_VIDEO_CONVERSION; data: IBaseJob }
@@ -120,6 +124,7 @@ export interface IJobRepository {
pause(name: QueueName): Promise<void>;
resume(name: QueueName): Promise<void>;
empty(name: QueueName): Promise<void>;
clear(name: QueueName, type: QueueCleanType): Promise<string[]>;
getQueueStatus(name: QueueName): Promise<QueueStatus>;
getJobCounts(name: QueueName): Promise<JobCounts>;
}