From 06661f44eb9c7c71af5dfae60be185dc3246613a Mon Sep 17 00:00:00 2001 From: Tom Hatzer <3952168+tomhatzer@users.noreply.github.com> Date: Sun, 24 Oct 2021 22:11:25 +0200 Subject: [PATCH 1/3] Add "No torrent found" message On a fresh install of the system, this command prints a log entry with an error every time it's executed. This creates a temporary model (new instead of create) that can be passed to the helper functions. This is a quick and dirty fix which should be thought about a little bit more, but it does its job for now. --- app/Console/Commands/AutoNerdStat.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/AutoNerdStat.php b/app/Console/Commands/AutoNerdStat.php index 8f5e6c27c1..76f4201674 100644 --- a/app/Console/Commands/AutoNerdStat.php +++ b/app/Console/Commands/AutoNerdStat.php @@ -75,13 +75,22 @@ public function handle() $banker = User::latest('seedbonus')->first(); // Most Snatched Torrent - $snatched = Torrent::latest('times_completed')->first(); + $snatched = Torrent::latest('times_completed')->firstOrNew([ + 'id' => null, + 'name' => 'No torrent found', + ]); // Most Seeded Torrent - $seeded = Torrent::latest('seeders')->first(); + $seeded = Torrent::latest('seeders')->first(OrNew([ + 'id' => null, + 'name' => 'No torrent found', + ]); // Most Leeched Torrent - $leeched = Torrent::latest('leechers')->first(); + $leeched = Torrent::latest('leechers')->first(OrNew([ + 'id' => null, + 'name' => 'No torrent found', + ]); // FL Torrents $fl = Torrent::where('free', '=', 1)->count(); From a0184602311a712cc170c911e8bd6e3c60cca671 Mon Sep 17 00:00:00 2001 From: Tom Hatzer <3952168+tomhatzer@users.noreply.github.com> Date: Sun, 24 Oct 2021 22:18:42 +0200 Subject: [PATCH 2/3] Remove additional character --- app/Console/Commands/AutoNerdStat.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/AutoNerdStat.php b/app/Console/Commands/AutoNerdStat.php index 76f4201674..f86ba21203 100644 --- a/app/Console/Commands/AutoNerdStat.php +++ b/app/Console/Commands/AutoNerdStat.php @@ -81,13 +81,13 @@ public function handle() ]); // Most Seeded Torrent - $seeded = Torrent::latest('seeders')->first(OrNew([ + $seeded = Torrent::latest('seeders')->firstOrNew([ 'id' => null, 'name' => 'No torrent found', ]); // Most Leeched Torrent - $leeched = Torrent::latest('leechers')->first(OrNew([ + $leeched = Torrent::latest('leechers')->firstOrNew([ 'id' => null, 'name' => 'No torrent found', ]); From 2169d6f2c6f3236d9186d194d27a8069750508b0 Mon Sep 17 00:00:00 2001 From: Tom Hatzer <3952168+tomhatzer@users.noreply.github.com> Date: Sun, 24 Oct 2021 22:19:39 +0200 Subject: [PATCH 3/3] Fix indentation --- app/Console/Commands/AutoNerdStat.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/AutoNerdStat.php b/app/Console/Commands/AutoNerdStat.php index f86ba21203..6879090c52 100644 --- a/app/Console/Commands/AutoNerdStat.php +++ b/app/Console/Commands/AutoNerdStat.php @@ -76,19 +76,19 @@ public function handle() // Most Snatched Torrent $snatched = Torrent::latest('times_completed')->firstOrNew([ - 'id' => null, + 'id' => null, 'name' => 'No torrent found', ]); // Most Seeded Torrent $seeded = Torrent::latest('seeders')->firstOrNew([ - 'id' => null, + 'id' => null, 'name' => 'No torrent found', ]); // Most Leeched Torrent $leeched = Torrent::latest('leechers')->firstOrNew([ - 'id' => null, + 'id' => null, 'name' => 'No torrent found', ]);