From 5773434a131a12787ed507f2cb638708d62a0c75 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 14 Oct 2019 21:31:57 -0600 Subject: [PATCH] Update AdminInstanceController, remove db transaction from instance scan --- .../Admin/AdminInstanceController.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Admin/AdminInstanceController.php b/app/Http/Controllers/Admin/AdminInstanceController.php index 5da2143f3..6dfa8d7bf 100644 --- a/app/Http/Controllers/Admin/AdminInstanceController.php +++ b/app/Http/Controllers/Admin/AdminInstanceController.php @@ -42,18 +42,18 @@ trait AdminInstanceController public function instanceScan(Request $request) { - DB::transaction(function() { - Profile::select('domain')->whereNotNull('domain') - ->groupBy('id') - ->groupBy('domain') - ->chunk(50, function($domains) { - foreach($domains as $domain) { - Instance::firstOrCreate([ - 'domain' => $domain->domain - ]); - } - }); + Profile::whereNotNull('domain') + ->latest() + ->groupBy('domain') + ->where('created_at', '>', now()->subMonths(2)) + ->chunk(100, function($domains) { + foreach($domains as $domain) { + Instance::firstOrCreate([ + 'domain' => $domain->domain + ]); + } }); + return redirect()->back(); }