Change our_nodes() to include only active zones/domains also. Updates to heartbeat
This commit is contained in:
parent
ae44732848
commit
aa55d05ccb
@ -7,7 +7,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Repat\LaravelJobs\Job;
|
||||
|
||||
use App\Models\{Address,Setup};
|
||||
use App\Models\Address;
|
||||
|
||||
class SystemHeartbeat #implements ShouldQueue
|
||||
{
|
||||
@ -25,37 +25,12 @@ class SystemHeartbeat #implements ShouldQueue
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
// Our zones
|
||||
$our_zones = our_address()->pluck('zone_id')->unique();
|
||||
|
||||
// Find our uplinks that are hubs, NC, RC or ZCs
|
||||
// Find any system that also has heartbeat configured
|
||||
$l = Address::select(['addresses.id','addresses.zone_id','addresses.region_id','addresses.host_id','addresses.node_id','addresses.point_id','role','addresses.system_id'])
|
||||
->distinct('systems.id')
|
||||
->join('systems',['systems.id'=>'addresses.system_id'])
|
||||
->join('system_zone',['system_zone.system_id'=>'systems.id'])
|
||||
->join('zones',['zones.id'=>'addresses.zone_id'])
|
||||
->join('domains',['domains.id'=>'zones.domain_id'])
|
||||
->where('systems.active',true)
|
||||
->where('addresses.active',TRUE)
|
||||
->where('zones.active',TRUE)
|
||||
->where('domains.active',TRUE)
|
||||
->whereIN('addresses.zone_id',$our_zones)
|
||||
->whereNotNull('pollmode')
|
||||
->where(function($query) {
|
||||
return $query
|
||||
->where('role','<',Address::NODE_NN)
|
||||
->orWhereNotNull('heartbeat');
|
||||
})
|
||||
->when(! $this->force,function($query) {
|
||||
return $query
|
||||
->where(function($query) {
|
||||
return $query->whereNull('autohold')
|
||||
->orWhere('autohold',FALSE);
|
||||
});
|
||||
})
|
||||
->with(['system','zone.domain'])
|
||||
->get();
|
||||
$l = our_nodes()
|
||||
->filter(fn($item)=>$item->heartbeat || ($item->role_id < Address::NODE_NN))
|
||||
->filter(fn($item)=>$this->force || (! $item->autohold))
|
||||
->unique(fn($item)=>$item->system_id);
|
||||
|
||||
// If we havent polled in heatbeat hours, poll system
|
||||
foreach ($l as $oo) {
|
||||
|
@ -77,13 +77,12 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
|
||||
public function addresses(): Collection
|
||||
{
|
||||
return Address::select('addresses.*')
|
||||
return Address::FTN()
|
||||
->join('systems',['systems.id'=>'addresses.system_id'])
|
||||
->join('system_user',['system_user.system_id'=>'systems.id'])
|
||||
->where('system_user.user_id',$this->id)
|
||||
->where('systems.active',TRUE)
|
||||
->ActiveFTN()
|
||||
->FTN()
|
||||
->get();
|
||||
}
|
||||
|
||||
|
@ -179,11 +179,12 @@ 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'])
|
||||
->join('zones',['zones.id'=>'system_zone.zone_id'])
|
||||
->join('domains',['domains.id'=>'zones.domain_id'])
|
||||
->when(! is_null($do),
|
||||
fn($query)=>$query
|
||||
->join('zones',['zones.id'=>'addresses.zone_id'])
|
||||
->where('domain_id',$do->id))
|
||||
->active()
|
||||
->ActiveFTN()
|
||||
->FTNorder()
|
||||
->get();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user