Merge pull request #2442 from CachetHQ/fix

Fixed scoping screw ups
This commit is contained in:
James Brooks
2017-03-19 10:05:34 +00:00
committed by GitHub

View File

@@ -49,9 +49,8 @@ class System implements SystemContract
*/ */
public function getStatus() public function getStatus()
{ {
$enabledScope = Component::enabled(); $totalComponents = Component::enabled()->count();
$totalComponents = (clone $enabledScope)->count(); $majorOutages = Component::enabled()->status(4)->count();
$majorOutages = (clone $enabledScope)->status(4)->count();
$isMajorOutage = $totalComponents ? ($majorOutages / $totalComponents) >= 0.5 : false; $isMajorOutage = $totalComponents ? ($majorOutages / $totalComponents) >= 0.5 : false;
// Default data // Default data
@@ -67,7 +66,7 @@ class System implements SystemContract
'system_message' => trans_choice('cachet.service.major', $totalComponents), 'system_message' => trans_choice('cachet.service.major', $totalComponents),
'favicon' => 'favicon-high-alert', 'favicon' => 'favicon-high-alert',
]; ];
} elseif ($enabledScope->notStatus(1)->count() === 0) { } elseif (Component::enabled()->notStatus(1)->count() === 0) {
// If all our components are ok, do we have any non-fixed incidents? // If all our components are ok, do we have any non-fixed incidents?
$incidents = Incident::orderBy('occurred_at', 'desc')->get()->filter(function ($incident) { $incidents = Incident::orderBy('occurred_at', 'desc')->get()->filter(function ($incident) {
return $incident->status !== Incident::FIXED; return $incident->status !== Incident::FIXED;
@@ -84,7 +83,7 @@ class System implements SystemContract
'favicon' => 'favicon', 'favicon' => 'favicon',
]; ];
} }
} elseif ($enabledScope->whereIn('status', [2, 3])->count() > 0) { } elseif (Component::enabled()->whereIn('status', [2, 3])->count() > 0) {
$status['favicon'] = 'favicon-medium-alert'; $status['favicon'] = 'favicon-medium-alert';
} }