From 2765a27db89bb7f54f54010d620bcaa51a764793 Mon Sep 17 00:00:00 2001 From: Deon George Date: Mon, 6 May 2024 08:23:07 +1000 Subject: [PATCH] Performance fix for address_merge, when there are a log of echomails to move to the new address --- app/Http/Controllers/SystemController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index d2f21d4..f7ed779 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -346,7 +346,11 @@ class SystemController extends Controller ->join('echomail_seenby',['echomail_seenby.echomail_id'=>'echomails.id']) ->whereIn('address_id',[$request->src]) ->distinct() - ->with(['seenby:id']) + ->with(['seenby'=>function($query) use ($request) { + return $query + ->select('id') + ->whereIn('address_id',[$request->src,$request->dst]); + }]) ->get() ->filter(function($item) use ($request) { return $item->seenby->contains($request->dst) && $item->seenby->contains($request->src);