Skip to content

Commit

Permalink
πŸ› Bug - fixed issue where uptime summary would be restricted by 30 days
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen Melbourne committed Oct 29, 2020
1 parent 0d8a9b6 commit b4c9b9c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app/HasUptime.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ trait HasUptime
{
private $limitResults = true;

public function setLimitResults($state)
{
$this->limitResults = $state;
}

public function uptimes()
{
$relationship = $this->hasMany(UptimeScan::class);
Expand Down Expand Up @@ -89,9 +94,12 @@ public function getCurrentStateAttribute()

public function getUptimeAttribute()
{
$latest = $this->uptimes->sortByDesc('created_at')->first();
$online = $this->uptimes->firstWhere('was_online', 1);
$offline = $this->uptimes->firstWhere('was_online', 0);
$child = Website::find($this->id);
$child->setLimitResults(false);

$latest = $child->uptimes()->orderBy('created_at')->take(1)->first();
$online = $child->uptimes()->firstWhere('was_online', 1);
$offline = $child->uptimes()->firstWhere('was_online', 0);

if (!$latest) {
return 'Still collecting data...';
Expand Down

0 comments on commit b4c9b9c

Please sign in to comment.