From 3c1b433c29abf14ceb4cd6d7dad80a278514455b Mon Sep 17 00:00:00 2001 From: Nabeel S Date: Thu, 30 Jan 2020 12:44:59 -0500 Subject: [PATCH] Reduce number of queries for update check (#520) --- app/Services/Installer/SeederService.php | 10 +++++----- .../Installer/Resources/views/flash/message.blade.php | 2 +- modules/Updater/Http/Controllers/UpdateController.php | 10 +++++++--- resources/views/admin/flash/message.blade.php | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/Services/Installer/SeederService.php b/app/Services/Installer/SeederService.php index 52ef793b..b38ebbf4 100644 --- a/app/Services/Installer/SeederService.php +++ b/app/Services/Installer/SeederService.php @@ -218,6 +218,7 @@ class SeederService extends Service */ private function settingsSeedsPending(): bool { + $all_settings = DB::table('settings')->get(); $data = file_get_contents(database_path('/seeds/settings.yml')); $yml = Yaml::parse($data); @@ -228,7 +229,7 @@ class SeederService extends Service } $id = Setting::formatKey($setting['key']); - $row = DB::table('settings')->where('id', $id)->first(); + $row = $all_settings->firstWhere('id', $id); // Doesn't exist in the table, quit early and say there is stuff pending if (!$row) { @@ -264,14 +265,13 @@ class SeederService extends Service */ private function permissionsSeedsPending(): bool { + $all_permissions = DB::table('permissions')->get(); + $data = file_get_contents(database_path('/seeds/permissions.yml')); $yml = Yaml::parse($data); foreach ($yml as $perm) { - $row = DB::table('permissions') - ->where('name', $perm['name']) - ->first(); - + $row = $all_permissions->firstWhere('name', $perm['name']); if (!$row) { return true; } diff --git a/modules/Installer/Resources/views/flash/message.blade.php b/modules/Installer/Resources/views/flash/message.blade.php index 5633dc36..d1e269b1 100644 --- a/modules/Installer/Resources/views/flash/message.blade.php +++ b/modules/Installer/Resources/views/flash/message.blade.php @@ -1,4 +1,4 @@ -@foreach (session('flash_notification', collect())->toArray() as $message) +@foreach (session('flash_notification', []) as $message)