Fix for addresses where region_id is set inlieu of host_id, sort system ZC addresses

This commit is contained in:
Deon George 2021-11-20 11:11:17 +11:00
parent 28cdedb327
commit 483e35202b
2 changed files with 23 additions and 2 deletions

View File

@ -13,6 +13,15 @@ use App\Classes\FTN\Packet;
use App\Http\Controllers\DomainController;
use App\Traits\{ScopeActive,UsePostgres};
/**
* @todo Need to stop this from happening:
* In this example nn:3/1 can be defined 3 different ways.
* + id | zone_id | region_id | host_id | node_id | point_id | status | role | system_id | hub_id
* + ----+---------+-----------+---------+---------+----------+--------+------+-----------+--------
* + 533 | 6 | 3 | 0 | 1 | 0 | | 4 | 1 |
* + 534 | 6 | 3 | 3 | 1 | 0 | | 2 | 1 |
* + 535 | 6 | 0 | 3 | 1 | 0 | | 2 | 1 |
*/
class Address extends Model
{
use ScopeActive,SoftDeletes,UsePostgres;
@ -184,6 +193,7 @@ class Address extends Model
case DomainController::NODE_UNKNOWN:
case DomainController::NODE_POINT:
case DomainController::NODE_DOWN:
// @todo Points - if the boss is defined, we should return it.
return NULL;
@ -298,7 +308,18 @@ class Address extends Model
$o = (new self)->active()
->select('addresses.*')
->where('zones.zone_id',$ftn['z'])
->where('host_id',$ftn['n'])
->where(function($q) use ($ftn) {
return $q->where(function($qq) use ($ftn) {
return $qq
->where('region_id',0)
->where('host_id',$ftn['n']);
})
->orWhere(function($qq) use ($ftn) {
return $qq
->where('region_id',$ftn['n'])
->where('host_id',0);
});
})
->where('node_id',$ftn['f'])
->where('point_id',$ftn['p'])
->join('zones',['zones.id'=>'addresses.zone_id'])

View File

@ -15,7 +15,7 @@ use App\Http\Controllers\DomainController as DC;
@endif
@if($o->zcs->count())
<p>This system is the ZC for the following zones: <strong class="highlight">{!! $o->zcs->map(function($item) { return sprintf('%d@%s',$item->zone_id,$item->domain->name); })->join('</strong>, <strong class="highlight">') !!} </strong></p>
<p>This system is the ZC for the following zones: <strong class="highlight">{!! $o->zcs->sortBy('zone_id')->map(function($item) { return sprintf('%d@%s',$item->zone_id,$item->domain->name); })->join('</strong>, <strong class="highlight">') !!} </strong></p>
@endif
<div class="accordion accordion-flush" id="accordion_homepage">