From b4c9b9c2355e9279537da6ec8233c073da1f2d88 Mon Sep 17 00:00:00 2001 From: Owen Melbourne Date: Thu, 29 Oct 2020 14:00:48 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Bug=20-=20fixed=20issue=20where?= =?UTF-8?q?=20uptime=20summary=20would=20be=20restricted=20by=2030=20days?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/HasUptime.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/HasUptime.php b/app/HasUptime.php index ab2025a..b288a11 100644 --- a/app/HasUptime.php +++ b/app/HasUptime.php @@ -8,6 +8,11 @@ trait HasUptime { private $limitResults = true; + public function setLimitResults($state) + { + $this->limitResults = $state; + } + public function uptimes() { $relationship = $this->hasMany(UptimeScan::class); @@ -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...';