Optimise queries for rendering the about page
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 33s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m38s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s

This commit is contained in:
2024-04-13 22:41:58 +10:00
parent 2edc41b11e
commit d6e23b9a90
7 changed files with 56 additions and 10 deletions

View File

@@ -91,16 +91,26 @@ if (! function_exists('hexstr')) {
*/
function our_address(Domain $do=NULL,Address $ao=NULL): Collection|Address|NULL
{
$our = Setup::findOrFail(config('app.id'))->system->akas;
static $so = NULL;
static $our = NULL;
if (! $so)
$so = Setup::findOrFail(config('app.id'));
if (! $our) {
$so->load(['system.akas.zone.domain']);
$our = $so->system->akas;
}
$filter = $our;
if ($do)
$our = $our->filter(function($item) use ($do) { return $item->zone->domain_id === $do->id; })->sortBy('role');
$filter = $our->filter(function($item) use ($do) { return $item->zone->domain_id === $do->id; })->sortBy('role');
// If we are looking for a specific address, and there is only 1 result, return it, otherwise return what we have
if ($ao && config('fido.strict') && ($x=$our->filter(function($item) use ($ao) { return $item->role <= $ao->role; })->sortBy('role'))->count())
if ($ao && config('fido.strict') && ($x=$filter->filter(function($item) use ($ao) { return $item->role <= $ao->role; })->sortBy('role'))->count())
$our = $x;
return $ao ? $our->last() : $our;
return $ao ? $our->last() : ($do ? $filter : $our);
}
/**