mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
Add statistic tracking
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Server\Http\Controllers\Admin;
|
||||
|
||||
use App\Contracts\ConnectionManager;
|
||||
use App\Contracts\StatisticsRepository;
|
||||
use App\Contracts\UserRepository;
|
||||
use App\Server\Configuration;
|
||||
use App\Server\Connections\ControlConnection;
|
||||
use Illuminate\Http\Request;
|
||||
use Ratchet\ConnectionInterface;
|
||||
|
||||
class GetStatisticsController extends AdminController
|
||||
{
|
||||
protected $keepConnectionOpen = true;
|
||||
|
||||
/** @var StatisticsRepository */
|
||||
protected $statisticsRepository;
|
||||
|
||||
public function __construct(StatisticsRepository $statisticsRepository)
|
||||
{
|
||||
$this->statisticsRepository = $statisticsRepository;
|
||||
}
|
||||
|
||||
public function handle(Request $request, ConnectionInterface $httpConnection)
|
||||
{
|
||||
$from = today()->subWeek()->toDateString();
|
||||
$until = today()->toDateString();
|
||||
|
||||
$this->statisticsRepository->getStatistics($request->get('from', $from), $request->get('until', $until))
|
||||
->then(function ($statistics) use ($httpConnection) {
|
||||
$httpConnection->send(
|
||||
respond_json([
|
||||
'statistics' => $statistics,
|
||||
])
|
||||
);
|
||||
|
||||
$httpConnection->close();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user