From 2680fe4c8e74d5d01ccce335bb52680af72be323 Mon Sep 17 00:00:00 2001 From: Jim C K Flaten Date: Mon, 28 Mar 2022 21:31:35 +0200 Subject: [PATCH] Feature/task order (#3807) --- app/Jobs/Schedule/RunTaskJob.php | 3 ++- app/Repositories/Eloquent/TaskRepository.php | 3 ++- .../components/server/schedules/ScheduleEditContainer.tsx | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Jobs/Schedule/RunTaskJob.php b/app/Jobs/Schedule/RunTaskJob.php index 0cffe4e85..fa62bc004 100644 --- a/app/Jobs/Schedule/RunTaskJob.php +++ b/app/Jobs/Schedule/RunTaskJob.php @@ -104,7 +104,8 @@ class RunTaskJob extends Job implements ShouldQueue { /** @var \Pterodactyl\Models\Task|null $nextTask */ $nextTask = Task::query()->where('schedule_id', $this->task->schedule_id) - ->where('sequence_id', $this->task->sequence_id + 1) + ->orderBy('sequence_id', 'asc') + ->where('sequence_id', '>', $this->task->sequence_id) ->first(); if (is_null($nextTask)) { diff --git a/app/Repositories/Eloquent/TaskRepository.php b/app/Repositories/Eloquent/TaskRepository.php index 718f99490..a375939ad 100644 --- a/app/Repositories/Eloquent/TaskRepository.php +++ b/app/Repositories/Eloquent/TaskRepository.php @@ -41,7 +41,8 @@ class TaskRepository extends EloquentRepository implements TaskRepositoryInterfa public function getNextTask(int $schedule, int $index) { return $this->getBuilder()->where('schedule_id', '=', $schedule) - ->where('sequence_id', '=', $index + 1) + ->orderBy('sequence_id', 'asc') + ->where('sequence_id', '>', $index) ->first($this->getColumns()); } } diff --git a/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx b/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx index fdd602304..88c85c5a8 100644 --- a/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx +++ b/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx @@ -139,7 +139,7 @@ export default () => {
{schedule.tasks.length > 0 ? - schedule.tasks.map(task => ( + schedule.tasks.sort((a, b) => a.sequenceId === b.sequenceId ? 0 : (a.sequenceId > b.sequenceId ? 1 : -1)).map(task => ( )) :