From c5621b82cfeddee23b81871a53035fde747f73a9 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Tue, 18 Dec 2018 02:23:44 +0100 Subject: Implemented /metrics endpoint and reimplemented /stats closes #418 (/metrics endpoint) Usage: ```yaml scrape_configs: - job_name: 'engelsystem' static_configs: - targets: ['engelsystem.example.com:80'] ``` --- includes/pages/guest_stats.php | 47 ------------------------------------------ 1 file changed, 47 deletions(-) delete mode 100644 includes/pages/guest_stats.php (limited to 'includes/pages/guest_stats.php') diff --git a/includes/pages/guest_stats.php b/includes/pages/guest_stats.php deleted file mode 100644 index d9012748..00000000 --- a/includes/pages/guest_stats.php +++ /dev/null @@ -1,47 +0,0 @@ -has('api_key')) { - if (!empty($apiKey) && $request->input('api_key') == $apiKey) { - $stats = []; - - $stats['user_count'] = User::all()->count(); - $stats['arrived_user_count'] = State::whereArrived(true)->count(); - - $done_shifts_seconds = DB::selectOne(' - SELECT SUM(`Shifts`.`end` - `Shifts`.`start`) - FROM `ShiftEntry` - JOIN `Shifts` USING (`SID`) - WHERE `Shifts`.`end` < UNIX_TIMESTAMP() - '); - $done_shifts_seconds = (int)array_shift($done_shifts_seconds); - $stats['done_work_hours'] = round($done_shifts_seconds / (60 * 60), 0); - - $users_in_action = DB::select(' - SELECT `Shifts`.`start`, `Shifts`.`end` - FROM `ShiftEntry` - JOIN `Shifts` ON `Shifts`.`SID`=`ShiftEntry`.`SID` - WHERE UNIX_TIMESTAMP() BETWEEN `Shifts`.`start` AND `Shifts`.`end` - '); - $stats['users_in_action'] = count($users_in_action); - - header('Content-Type: application/json'); - raw_output(json_encode($stats)); - return; - } - raw_output(json_encode([ - 'error' => 'Wrong api_key.' - ])); - } - raw_output(json_encode([ - 'error' => 'Missing parameter api_key.' - ])); -} -- cgit v1.2.3-54-g00ecf