Skip to content

Commit

Permalink
Only be paused if everything is paused
Browse files Browse the repository at this point in the history
  • Loading branch information
glamorous committed Nov 20, 2020
1 parent 5c00193 commit dd7388c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions resources/js/screens/dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
</svg>

<h4 class="mb-0 ml-2">{{ {running: 'Active', paused: 'Paused', inactive:'Inactive'}[stats.status] }}</h4>
<small v-if="stats.status == 'running' && stats.pausedMasters > 0" class="mb-0 ml-2">({{ stats.pausedMasters }} paused)</small>
</div>
</div>
</div>
Expand Down
19 changes: 18 additions & 1 deletion src/Http/Controllers/DashboardStatsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function index()
'failedJobs' => app(JobRepository::class)->countRecentlyFailed(),
'recentJobs' => app(JobRepository::class)->countRecent(),
'status' => $this->currentStatus(),
'pausedMasters' => $this->countPausedMasters(),
'wait' => collect(app(WaitTimeCalculator::class)->calculate())->take(1),
'periods' => [
'failedJobs' => config('horizon.trim.recent_failed', config('horizon.trim.failed')),
Expand Down Expand Up @@ -58,8 +59,24 @@ protected function currentStatus()
return 'inactive';
}

return collect($masters)->contains(function ($master) {
return collect($masters)->every(function ($master) {
return $master->status === 'paused';
}) ? 'paused' : 'running';
}

/**
* Get paused masters.
*
* @return int
*/
protected function countPausedMasters()
{
if (! $masters = app(MasterSupervisorRepository::class)->all()) {
return 0;
}

return collect($masters)->filter(function ($master) {
return $master->status === 'paused';
})->count();
}
}

0 comments on commit dd7388c

Please sign in to comment.