| Conditions | 1 |
| Paths | 1 |
| Total Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | public function __invoke($appId) |
||
| 8 | { |
||
| 9 | $webSocketsStatisticsEntryModelClass = config('websockets.statistics.model'); |
||
| 10 | $statistics = $webSocketsStatisticsEntryModelClass::where('app_id', $appId)->latest()->limit(120)->get(); |
||
| 11 | |||
| 12 | $statisticData = $statistics->map(function ($statistic) { |
||
| 13 | return [ |
||
| 14 | 'timestamp' => (string) $statistic->created_at, |
||
| 15 | 'peak_connection_count' => $statistic->peak_connection_count, |
||
| 16 | 'websocket_message_count' => $statistic->websocket_message_count, |
||
| 17 | 'api_message_count' => $statistic->api_message_count, |
||
| 18 | ]; |
||
| 19 | })->reverse(); |
||
| 20 | |||
| 21 | return [ |
||
| 22 | 'peak_connections' => [ |
||
| 23 | 'x' => $statisticData->pluck('timestamp'), |
||
| 24 | 'y' => $statisticData->pluck('peak_connection_count'), |
||
| 25 | ], |
||
| 26 | 'websocket_message_count' => [ |
||
| 27 | 'x' => $statisticData->pluck('timestamp'), |
||
| 28 | 'y' => $statisticData->pluck('websocket_message_count'), |
||
| 29 | ], |
||
| 30 | 'api_message_count' => [ |
||
| 31 | 'x' => $statisticData->pluck('timestamp'), |
||
| 32 | 'y' => $statisticData->pluck('api_message_count'), |
||
| 33 | ], |
||
| 34 | ]; |
||
| 35 | } |
||
| 36 | } |
||
| 37 |