librenms/app/Listeners/UpdateDeviceGroups.php
Jellyfrog 2b3575a5e9
Laravel 10.x Shift (#14995)
* Apply code style

* Remove explicit call to register policies

* Shift core files

* Shift config files

* Default config files

In an effort to make upgrading the constantly changing config files
easier, Shift defaulted them and merged your true customizations -
where ENV variables may not be used.

* Bump Laravel dependencies

* Add type hints for Laravel 10

* Shift cleanup

* wip

* wip

* sync translation

* Sync back config

* Public Path Binding

* QueryException

* monolog

* db::raw

* monolog

* db::raw

* fix larastan collections

* fix phpstan bug looping forever

* larastan errors

* larastan: fix column type

* styleci

* initialize array

* fixes

* fixes

---------

Co-authored-by: Shift <shift@laravelshift.com>
2023-05-24 22:21:54 +02:00

44 lines
990 B
PHP

<?php
namespace App\Listeners;
use App\Action;
use App\Actions\Device\UpdateDeviceGroupsAction;
use App\Events\DevicePolled;
use Log;
class UpdateDeviceGroups
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param DevicePolled $event
* @return void
*/
public function handle(DevicePolled $event): void
{
Log::info('### Start Device Groups ###');
$dg_start = microtime(true);
// update device groups
$group_changes = Action::execute(UpdateDeviceGroupsAction::class, $event->device);
$added = implode(',', $group_changes['attached']);
$removed = implode(',', $group_changes['detached']);
$elapsed = round(microtime(true) - $dg_start, 4);
Log::debug("Groups Added: $added Removed: $removed");
Log::info("### End Device Groups ({$elapsed}s) ### \n");
}
}