Skip to content

Commit

Permalink
Minor code hardening.
Browse files Browse the repository at this point in the history
Changed term to “Delayed Processing”
  • Loading branch information
heathdutton committed Jun 1, 2018
1 parent 2075739 commit 93ad84b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
60 changes: 31 additions & 29 deletions Integration/HealthIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function setComponentStatus($incidentStatus = null, $componentStatus = nu
if (!empty($featureSettings['statuspage_component_id'])) {
$components = $this->getComponents();
foreach ($components as $component) {
if ($component['id'] === $featureSettings['statuspage_component_id']) {
if (isset($component['id']) && $component['id'] === $featureSettings['statuspage_component_id']) {
// Update the component status if needed.
if ($componentStatus !== $component['status']) {
$clientIdKey = $this->getClientIdKey();
Expand All @@ -55,39 +55,41 @@ public function setComponentStatus($incidentStatus = null, $componentStatus = nu
$componentIds[] = $component['id'];
if (count($incidents)) {
foreach ($incidents as $incident) {
$change = false;
if ($incident['status'] !== $incidentStatus) {
$change = true;
}
if (!empty($incident['incident_updates'])) {
// Get the latest incident update.
$updates = [];
foreach ($incident['incident_updates'] as $update) {
$updates[$update['updated_at']] = $update;
}
ksort($updates);
$lastUpdate = end($updates);
if ($lastUpdate['body'] !== $body) {
if (isset($incident['id'])) {
$change = false;
if ($incident['status'] !== $incidentStatus) {
$change = true;
}
}
if ($change) {
// Update/Close the incident.
if (!empty($lastUpdate)) {
foreach ($lastUpdate['affected_components'] as $affectedComponent) {
if (!empty($affectedComponent['id'])) {
$componentIds[] = $affectedComponent['id'];
if (!empty($incident['incident_updates'])) {
// Get the latest incident update.
$updates = [];
foreach ($incident['incident_updates'] as $update) {
$updates[$update['updated_at']] = $update;
}
ksort($updates);
$lastUpdate = end($updates);
if ($lastUpdate['body'] !== $body) {
$change = true;
}
}
if ($change) {
// Update/Close the incident.
if (!empty($lastUpdate)) {
foreach ($lastUpdate['affected_components'] as $affectedComponent) {
if (!empty($affectedComponent['id'])) {
$componentIds[] = $affectedComponent['id'];
}
}
}
$componentIds = array_unique($componentIds);
$this->updateIncident(
$incident['id'],
$incidentStatus,
$name,
$body,
$componentIds
);
}
$componentIds = array_unique($componentIds);
$this->updateIncident(
$incident['id'],
$incidentStatus,
$name,
$body,
$componentIds
);
}
}
} elseif ('resolved' !== $incidentStatus) {
Expand Down
2 changes: 1 addition & 1 deletion Model/HealthModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function reportIncidents(OutputInterface $output = null)
return;
}
if ($this->incidents && !empty($this->settings['statuspage_component_id'])) {
$name = 'Degraded Performance';
$name = 'Processing Delays';
$body = [];
foreach ($this->incidents as $campaignId => $campaign) {
foreach ($campaign as $incident) {
Expand Down

0 comments on commit 93ad84b

Please sign in to comment.