mirror of
https://github.com/v2board/v2board.git
synced 2025-01-11 00:29:09 +08:00
update
This commit is contained in:
parent
89a8fc9a00
commit
7abcad6970
@ -70,8 +70,8 @@ class SystemCache extends Command
|
|||||||
private function setMonthServerTrafficTotal () {
|
private function setMonthServerTrafficTotal () {
|
||||||
$servers = Server::get();
|
$servers = Server::get();
|
||||||
foreach ($servers as $item) {
|
foreach ($servers as $item) {
|
||||||
$serverLog = ServerLog::where('created_at', '>=', $item->created_at)
|
$serverLog = ServerLog::where('created_at', '>=', strtotime(date('Y-m-1')))
|
||||||
->where('created_at', '<', strtotime('+1 month', $item->created_at))
|
->where('created_at', '<', time())
|
||||||
->where('node_id', $item->id);
|
->where('node_id', $item->id);
|
||||||
Redis::set('month_server_traffic_total_u_' . $item->id, $serverLog->sum('u'));
|
Redis::set('month_server_traffic_total_u_' . $item->id, $serverLog->sum('u'));
|
||||||
Redis::set('month_server_traffic_total_d_' . $item->id, $serverLog->sum('d'));
|
Redis::set('month_server_traffic_total_d_' . $item->id, $serverLog->sum('d'));
|
||||||
|
37
app/Events/ServerCreatedEvent.php
Normal file
37
app/Events/ServerCreatedEvent.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use App\Models\ServerLog;
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
|
||||||
|
class ServerCreatedEvent
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
public $serverLog;
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(ServerLog $serverLog) {
|
||||||
|
$this->serverLog = $serverLog;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
30
app/Listeners/ServerCreatedListener.php
Normal file
30
app/Listeners/ServerCreatedListener.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use App\Events\ServerCreatedEvent;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
class ServerCreatedListener
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param ServerCreatedEvent $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle(ServerCreatedEvent $event) {
|
||||||
|
info('listener', $event->serverLog);
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Events\ServerLogSaveEvent;
|
use App\Events\ServerCreatedEvent;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class ServerLog extends Model
|
class ServerLog extends Model
|
||||||
@ -10,5 +10,6 @@ class ServerLog extends Model
|
|||||||
protected $table = 'v2_server_log';
|
protected $table = 'v2_server_log';
|
||||||
protected $dateFormat = 'U';
|
protected $dateFormat = 'U';
|
||||||
protected $dispatchesEvents = [
|
protected $dispatchesEvents = [
|
||||||
|
'created' => ServerCreatedEvent::class
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,9 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $listen = [
|
protected $listen = [
|
||||||
|
'App\Events\ServerCreatedEvent' => [
|
||||||
|
'App\Listeners\ServerCreatedListener',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user