Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Commit

Permalink
Apply fixes from StyleCI (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelien committed Jan 27, 2018
1 parent de12c9b commit 79f2e8e
Show file tree
Hide file tree
Showing 7 changed files with 462 additions and 424 deletions.
1 change: 1 addition & 0 deletions index.php
@@ -1,3 +1,4 @@
<?php

header('Location: public/vps.php');
exit();
65 changes: 33 additions & 32 deletions public/alert-xhr.php
@@ -1,4 +1,5 @@
<?php

require '../vendor/autoload.php';

$ini = parse_ini_file('../monitoring.ini');
Expand All @@ -8,70 +9,70 @@

$status = $ovh->get('/status/task');

$result = array();
$result = [];

foreach ($status as $s) {
if (isset($_GET['cloud']) && $s['project'] !== 'PublicCloud') {
continue;
}
if (isset($_GET['vps']) && $s['project'] !== 'VPS') {
continue;
}

if ($s['project'] === 'PublicCloud') {
if (!isset($result[$s['impactedService']])) {
$result[$s['impactedService']] = array();
if (isset($_GET['cloud']) && $s['project'] !== 'PublicCloud') {
continue;
}
if (!isset($result[$s['impactedService']][$s['uuid']])) {
$result[$s['impactedService']][$s['uuid']] = array(
'status' => NULL,
'alerts' => array()
);
if (isset($_GET['vps']) && $s['project'] !== 'VPS') {
continue;
}

$result[$s['impactedService']][$s['uuid']]['alerts'][] = $s;
if ($s['project'] === 'PublicCloud') {
if (!isset($result[$s['impactedService']])) {
$result[$s['impactedService']] = [];
}
if (!isset($result[$s['impactedService']][$s['uuid']])) {
$result[$s['impactedService']][$s['uuid']] = [
'status' => null,
'alerts' => [],
];
}

$result[$s['impactedService']][$s['uuid']]['alerts'][] = $s;

switch ($s['status']) {
switch ($s['status']) {
case 'planned':
if ($result[$s['impactedService']][$s['uuid']]['status'] !== 'inProgress') {
$result[$s['impactedService']][$s['uuid']]['status'] = 'planned';
$result[$s['impactedService']][$s['uuid']]['status'] = 'planned';
}
break;
case 'inProgress':
$result[$s['impactedService']][$s['uuid']]['status'] = 'inProgress';
break;
case 'finished':
if ($result[$s['impactedService']][$s['uuid']]['status'] !== 'inProgress' && $result[$s['impactedService']][$s['uuid']]['status'] !== 'planned') {
$result[$s['impactedService']][$s['uuid']]['status'] = 'finished';
$result[$s['impactedService']][$s['uuid']]['status'] = 'finished';
}
break;
}
} else {
if (!isset($result[$s['impactedService']])) {
$result[$s['impactedService']] = array(
'status' => NULL,
'alerts' => array()
);
}
} else {
if (!isset($result[$s['impactedService']])) {
$result[$s['impactedService']] = [
'status' => null,
'alerts' => [],
];
}

$result[$s['impactedService']]['alerts'][] = $s;
$result[$s['impactedService']]['alerts'][] = $s;

switch ($s['status']) {
switch ($s['status']) {
case 'planned':
if ($result[$s['impactedService']]['status'] !== 'inProgress') {
$result[$s['impactedService']]['status'] = 'planned';
$result[$s['impactedService']]['status'] = 'planned';
}
break;
case 'inProgress':
$result[$s['impactedService']]['status'] = 'inProgress';
break;
case 'finished':
if ($result[$s['impactedService']]['status'] !== 'inProgress' && $result[$s['impactedService']]['status'] !== 'planned') {
$result[$s['impactedService']]['status'] = 'finished';
$result[$s['impactedService']]['status'] = 'finished';
}
break;
}
}
}
}

echo json_encode($result);
Expand Down

0 comments on commit 79f2e8e

Please sign in to comment.