mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Apply fixes from StyleCI (#12124)
This commit is contained in:
@@ -57,10 +57,10 @@ class Component
|
||||
public function getComponentType($TYPE = null)
|
||||
{
|
||||
if (is_null($TYPE)) {
|
||||
$SQL = "SELECT DISTINCT `type` as `name` FROM `component` ORDER BY `name`";
|
||||
$SQL = 'SELECT DISTINCT `type` as `name` FROM `component` ORDER BY `name`';
|
||||
$row = dbFetchRow($SQL, []);
|
||||
} else {
|
||||
$SQL = "SELECT DISTINCT `type` as `name` FROM `component` WHERE `type` = ? ORDER BY `name`";
|
||||
$SQL = 'SELECT DISTINCT `type` as `name` FROM `component` WHERE `type` = ? ORDER BY `name`';
|
||||
$row = dbFetchRow($SQL, [$TYPE]);
|
||||
}
|
||||
|
||||
@@ -121,13 +121,13 @@ class Component
|
||||
|
||||
public function getComponentStatus($device = null)
|
||||
{
|
||||
$sql_query = "SELECT status, count(status) as count FROM component WHERE";
|
||||
$sql_query = 'SELECT status, count(status) as count FROM component WHERE';
|
||||
$sql_param = [];
|
||||
$add = 0;
|
||||
|
||||
if (! is_null($device)) {
|
||||
// Add a device filter to the SQL query.
|
||||
$sql_query .= " `device_id` = ?";
|
||||
$sql_query .= ' `device_id` = ?';
|
||||
$sql_param[] = $device;
|
||||
$add++;
|
||||
}
|
||||
@@ -136,8 +136,8 @@ class Component
|
||||
// No filters, remove " WHERE" -6
|
||||
$sql_query = substr($sql_query, 0, strlen($sql_query) - 6);
|
||||
}
|
||||
$sql_query .= " GROUP BY status";
|
||||
d_echo("SQL Query: " . $sql_query);
|
||||
$sql_query .= ' GROUP BY status';
|
||||
d_echo('SQL Query: ' . $sql_query);
|
||||
|
||||
// $service is not null, get only what we want.
|
||||
$result = dbFetchRows($sql_query, $sql_param);
|
||||
@@ -149,7 +149,7 @@ class Component
|
||||
$count[$v['status']] = $v['count'];
|
||||
}
|
||||
|
||||
d_echo("Component Count by Status: " . print_r($count, true) . "\n");
|
||||
d_echo('Component Count by Status: ' . print_r($count, true) . "\n");
|
||||
|
||||
return $count;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ class Component
|
||||
{
|
||||
if (($component_id == null) || ($start == null) || ($end == null)) {
|
||||
// Error...
|
||||
d_echo("Required arguments are missing. Component ID: " . $component_id . ", Start: " . $start . ", End: " . $end . "\n");
|
||||
d_echo('Required arguments are missing. Component ID: ' . $component_id . ', Start: ' . $start . ', End: ' . $end . "\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ class Component
|
||||
$return = [];
|
||||
|
||||
// 1. find the previous value, this is the value when $start occurred.
|
||||
$sql_query = "SELECT status FROM `component_statuslog` WHERE `component_id` = ? AND `timestamp` < ? ORDER BY `id` desc LIMIT 1";
|
||||
$sql_query = 'SELECT status FROM `component_statuslog` WHERE `component_id` = ? AND `timestamp` < ? ORDER BY `id` desc LIMIT 1';
|
||||
$sql_param = [$component_id, $start];
|
||||
$result = dbFetchRow($sql_query, $sql_param);
|
||||
if ($result == false) {
|
||||
@@ -177,11 +177,11 @@ class Component
|
||||
}
|
||||
|
||||
// 2. Then we just need a list of all the entries for the time period.
|
||||
$sql_query = "SELECT status, `timestamp`, message FROM `component_statuslog` WHERE `component_id` = ? AND `timestamp` >= ? AND `timestamp` < ? ORDER BY `timestamp`";
|
||||
$sql_query = 'SELECT status, `timestamp`, message FROM `component_statuslog` WHERE `component_id` = ? AND `timestamp` >= ? AND `timestamp` < ? ORDER BY `timestamp`';
|
||||
$sql_param = [$component_id, $start, $end];
|
||||
$return['data'] = dbFetchRows($sql_query, $sql_param);
|
||||
|
||||
d_echo("Status Log Data: " . print_r($return, true) . "\n");
|
||||
d_echo('Status Log Data: ' . print_r($return, true) . "\n");
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -202,7 +202,7 @@ class Component
|
||||
try {
|
||||
return ComponentStatusLog::create(['component_id' => $component_id, 'status' => $status, 'message' => $message])->id;
|
||||
} catch (\Exception $e) {
|
||||
Log::debug("Failed to create component status log");
|
||||
Log::debug('Failed to create component status log');
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -235,7 +235,7 @@ class Component
|
||||
|
||||
// If the Status has changed we need to add a log entry
|
||||
if ($component->isDirty('status')) {
|
||||
Log::debug("Status Changed - Old: " . $component->getOriginal('status') . ", New: $component->status\n");
|
||||
Log::debug('Status Changed - Old: ' . $component->getOriginal('status') . ", New: $component->status\n");
|
||||
$this->createStatusLogEntry($component->id, $component->status, $component->error);
|
||||
}
|
||||
$component->save();
|
||||
|
Reference in New Issue
Block a user