Optimise the queries used to display packet contents and show DBID if msgid is not available
This commit is contained in:
@@ -44,8 +44,7 @@ class HomeController extends Controller
|
||||
|
||||
public function packet_contents(System $o,string $packet)
|
||||
{
|
||||
$nm = Netmail::select('netmails.*')
|
||||
->distinct()
|
||||
$nm = Netmail::select(['netmails.id','fftn_id','tftn_id','netmails.datetime'])
|
||||
->leftJoin('netmail_path',['netmail_path.netmail_id'=>'netmails.id'])
|
||||
->where(function($query) use ($o,$packet) {
|
||||
return $query
|
||||
@@ -54,21 +53,23 @@ class HomeController extends Controller
|
||||
})
|
||||
->get();
|
||||
|
||||
$em = Echomail::select('echomails.*')
|
||||
->distinct()
|
||||
$em = Echomail::select(['echomails.id','fftn_id','echoarea_id','msgid','datetime'])
|
||||
->leftJoin('echomail_seenby',['echomail_seenby.echomail_id'=>'echomails.id'])
|
||||
->leftJoin('echomail_path',['echomail_path.echomail_id'=>'echomails.id'])
|
||||
->where(function($query) use ($o,$packet) {
|
||||
return $query
|
||||
->where('sent_pkt',$packet)
|
||||
->whereIn('echomail_seenby.address_id',$o->addresses->pluck('id'));
|
||||
})
|
||||
->orWhere(function($query) use ($o,$packet) {
|
||||
return $query
|
||||
->where('recv_pkt',$packet)
|
||||
->whereIn('echomail_path.address_id',$o->addresses->pluck('id'));
|
||||
})
|
||||
->with('echoarea')
|
||||
})
|
||||
->union(
|
||||
Echomail::select(['echomails.id','fftn_id','echoarea_id','msgid','datetime'])
|
||||
->leftJoin('echomail_path',['echomail_path.echomail_id'=>'echomails.id'])
|
||||
->where(function($query) use ($o,$packet) {
|
||||
return $query
|
||||
->where('recv_pkt',$packet)
|
||||
->whereIn('echomail_path.address_id',$o->addresses->pluck('id'));
|
||||
})
|
||||
)
|
||||
->with(['echoarea'])
|
||||
->get();
|
||||
|
||||
return view('packet')
|
||||
|
Reference in New Issue
Block a user