Skip to content

Commit

Permalink
Add remaining seconds calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
romanzipp committed Sep 10, 2018
1 parent 7f2b0f2 commit 1709720
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/Models/Monitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,29 @@ public function getBasenameAttribute()
return Arr::last(explode('\\', $this->name));
}

public function basename()
public function getParsedDataAttribute(): array
{
return $this->basename;
return json_decode($this->data, true) ?? [];
}

public function getParsedDataAttribute(): array
public function getRemainingSecondsAttribute(): ?float
{
return json_decode($this->data, true) ?? [];
if ($this->isFinished()) {
return null;
}

if ($this->progress === null) {
return null;
}

$secondsRunning = now()->getTimestamp() - $this->created_at->getTimestamp();

return (float) ($secondsRunning - ($secondsRunning * $this->progress / 100));
}

public function basename()
{
return $this->basename;
}

/**
Expand Down

0 comments on commit 1709720

Please sign in to comment.