Mail bundling and processing performance improvements
This commit is contained in:
@@ -98,7 +98,12 @@ function our_address(Domain|Address $o=NULL): Collection|Address|NULL
|
||||
});
|
||||
|
||||
$our = Cache::remember(sprintf('%d-akas',$so->system_id),60,function() use ($so) {
|
||||
$so->load(['system.akas.zone.domain']);
|
||||
$so->load([
|
||||
'system:id,name',
|
||||
'system.akas:addresses.id,addresses.zone_id,host_id,node_id,point_id,addresses.system_id,addresses.active,role',
|
||||
'system.akas.zone:id,domain_id,zone_id',
|
||||
'system.akas.zone.domain:id,name',
|
||||
]);
|
||||
|
||||
return $so->system->akas;
|
||||
});
|
||||
@@ -114,16 +119,20 @@ function our_address(Domain|Address $o=NULL): Collection|Address|NULL
|
||||
// We are requesting a list of addresses for a Domain, or a specific Address, and we have more than 1
|
||||
switch (get_class($o)) {
|
||||
case Address::class:
|
||||
$filter = $our->filter(function($item) use ($o) { return $item->zone->domain_id === $o->zone->domain_id; })->sortBy('role');
|
||||
$filter = $our
|
||||
->filter(fn($item)=>$item->zone->domain_id === $o->zone->domain_id)
|
||||
->sortBy('role_id');
|
||||
|
||||
// If we are looking for a specific address, and there is only 1 result, return it, otherwise return what we have
|
||||
if (config('fido.strict') && ($x=$filter->filter(function($item) use ($o) { return $item->role_id <= $o->role_id; })->sortBy('role'))->count())
|
||||
if (config('fido.strict') && ($x=$filter->filter(fn($item)=>$item->role_id <= $o->role_id)->sortBy('role_id'))->count())
|
||||
$filter = $x;
|
||||
|
||||
return $filter->last();
|
||||
return $filter->count() ? $filter->last()->unsetRelation('nodes_hub') : NULL;
|
||||
|
||||
case Domain::class:
|
||||
return $our->filter(function($item) use ($o) { return $item->zone->domain_id === $o->id; })->sortBy('role');
|
||||
return $our
|
||||
->filter(fn($item)=>$item->zone->domain_id === $o->id)
|
||||
->sortBy('role_id');
|
||||
|
||||
// We shouldnt get here
|
||||
default:
|
||||
@@ -171,11 +180,10 @@ function our_nodes(Domain $do=NULL): Collection
|
||||
{
|
||||
return Address::select(['addresses.id','addresses.zone_id','region_id','host_id','node_id','point_id','addresses.system_id','role'])
|
||||
->join('system_zone',['system_zone.system_id'=>'addresses.system_id','system_zone.zone_id'=>'addresses.zone_id'])
|
||||
->when(! is_null($do),function($query) use ($do) {
|
||||
return $query
|
||||
->when(! is_null($do),
|
||||
fn($query)=>$query
|
||||
->join('zones',['zones.id'=>'addresses.zone_id'])
|
||||
->where('domain_id',$do->id);
|
||||
})
|
||||
->where('domain_id',$do->id))
|
||||
->active()
|
||||
->FTNorder()
|
||||
->get();
|
||||
|
Reference in New Issue
Block a user