Skip to content
Snippets Groups Projects
Commit bbd84a07 authored by Tibo's avatar Tibo
Browse files

Fix code style

parent 269289af
No related branches found
No related tags found
No related merge requests found
Pipeline #2095 passed
......@@ -2,7 +2,8 @@
namespace App\Sensor;
class DiskEvolution extends \App\AbstractSensor {
class DiskEvolution extends \App\AbstractSensor
{
/**
......@@ -10,7 +11,8 @@ class DiskEvolution extends \App\AbstractSensor {
* @param Partition[] $newAndOld
* @return \App\Sensor\Delta[]
*/
public function computeEvolution(array $newAndOld, int $timeDifference) : array {
public function computeEvolution(array $newAndOld, int $timeDifference) : array
{
foreach ($newAndOld[0] as $key => $partition) {
$delta = new Delta();
......@@ -18,7 +20,7 @@ class DiskEvolution extends \App\AbstractSensor {
$delta->delta = $partition->used - $newAndOld[1][$key]->used;
if ($delta->delta == 0) {
$delta->timeUntillFull = PHP_INT_MAX;
} else {
} else {
$delta->timeUntillFull = ($partition->blocks - $partition->used) / $delta->delta * $timeDifference;
}
$deltas[] = $delta;
......@@ -33,7 +35,8 @@ class DiskEvolution extends \App\AbstractSensor {
*
* @param int $timeInterval in hours
*/
public function get2Partitions(int $timeInterval) {
public function get2Partitions(int $timeInterval)
{
$records = $this->getLastRecords("disks", $timeInterval * 12);
$newPartitions = Disks::parse($records[0]->disks);
$oldPartitions = Disks::parse($records[count($records) - 1]->disks);
......@@ -42,7 +45,8 @@ class DiskEvolution extends \App\AbstractSensor {
}
// code to print the results
public function printResults($deltas) {
public function printResults($deltas)
{
$return = "<table class='table table-sm'>";
$return .= "<tr><th>name</th><th>time untill full (h)</th></tr>";
......@@ -57,12 +61,15 @@ class DiskEvolution extends \App\AbstractSensor {
return $return;
}
public function report() {
public function report()
{
return $this->printResults(
$this->computeEvolution($this->get2Partitions(24), 24));
$this->computeEvolution($this->get2Partitions(24), 24)
);
}
public function status() {
public function status()
{
$deltas = $this->computeEvolution($this->get2Partitions(24), 24);
return $this->computeStatusFromDeltas($deltas);
......
......@@ -8,7 +8,6 @@ use App\Organization;
use App\Server;
use App\Sensor\Disks;
use App\Sensor\Ifconfig;
use App\Sensor\Partition;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment