| 107 | } |
| 108 | |
| 109 | async runCommandLegacy(name: QueueName, dto: QueueCommandDto): Promise<QueueResponseLegacyDto> { |
| 110 | this.logger.debug(`Handling command: queue=${name},command=${dto.command},force=${dto.force}`); |
| 111 | |
| 112 | switch (dto.command) { |
| 113 | case QueueCommand.Start: { |
| 114 | await this.start(name, dto); |
| 115 | break; |
| 116 | } |
| 117 | |
| 118 | case QueueCommand.Pause: { |
| 119 | await this.jobRepository.pause(name); |
| 120 | break; |
| 121 | } |
| 122 | |
| 123 | case QueueCommand.Resume: { |
| 124 | await this.jobRepository.resume(name); |
| 125 | break; |
| 126 | } |
| 127 | |
| 128 | case QueueCommand.Empty: { |
| 129 | await this.jobRepository.empty(name); |
| 130 | break; |
| 131 | } |
| 132 | |
| 133 | case QueueCommand.ClearFailed: { |
| 134 | const failedJobs = await this.jobRepository.clear(name, QueueCleanType.Failed); |
| 135 | this.logger.debug(`Cleared failed jobs: ${failedJobs}`); |
| 136 | break; |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | const response = await this.getByName(name); |
| 141 | |
| 142 | return mapQueueLegacy(response); |
| 143 | } |
| 144 | |
| 145 | async getAll(_auth: AuthDto): Promise<QueueResponseDto[]> { |
| 146 | return Promise.all(Object.values(QueueName).map((name) => this.getByName(name))); |