Optimise the queries used to display packet contents and show DBID if msgid is not available

This commit is contained in:
Deon George 2023-11-23 21:55:39 +11:00
parent b3dfca5b89
commit 19338edcb6
4 changed files with 23 additions and 15 deletions

View File

@ -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')

View File

@ -154,7 +154,8 @@ final class Netmail extends Model implements Packet
public function tftn()
{
return $this
->belongsTo(Address::class);
->belongsTo(Address::class)
->withTrashed();
}
/* METHODS */

View File

@ -17,7 +17,13 @@
<tr>
<td>{{ $oo->fftn->ftn }}</td>
<td>{{ $oo->tftn->ftn }}</td>
<td>{{ $oo->msgid }}</td>
<td>
@if ($oo->msgid)
{{ $oo->msgid }}
@else
<small>[{{ $oo->id }}]</small>
@endif
</td>
<td>{{ $oo->datetime }}</td>
</tr>
@endforeach

View File

@ -64,7 +64,7 @@ use App\Classes\FTN\Message;
<div class="col-8">
PATH: <br><strong class="highlight">{!! optimize_path($msg->pathorder())->join('</strong> -> <strong class="highlight">') !!}</strong>
@if ($msg->rogue_path->count())
@if (($msg instanceof \App\Models\Echomail) && $msg->rogue_path->count())
<br><small>[<strong>NOTE</strong>: Some path values couldnt be identified - ({{ $msg->rogue_path->join(',') }})]</small>
@endif
</div>