From 6ffb1b5c4da09857a8e3e785d5dc69ba92277555 Mon Sep 17 00:00:00 2001 From: Dominik Pfennig <dominik@suma-ev.de> Date: Thu, 22 Sep 2016 07:58:59 +0200 Subject: [PATCH] =?UTF-8?q?Interface=20zum=20auslesen=20der=20Statistik=20?= =?UTF-8?q?hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/AdminInterface.php | 33 +++++++++++++++ app/Http/routes.php | 1 + resources/views/admin/engines.blade.php | 54 +++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 resources/views/admin/engines.blade.php diff --git a/app/Http/Controllers/AdminInterface.php b/app/Http/Controllers/AdminInterface.php index c7cd810f0..959b2ca2f 100644 --- a/app/Http/Controllers/AdminInterface.php +++ b/app/Http/Controllers/AdminInterface.php @@ -96,4 +96,37 @@ class AdminInterface extends Controller ->with('title', 'Wer sucht was? - MetaGer') ->with('q', $q); } + + public function engines() + { + # Wir laden den Inhalt der Log Datei und übergeben ihn an den view + $file = "/var/log/metager/engine.log"; + if (file_exists($file) && is_readable($file)) { + $engineStats = file_get_contents($file); + # Daten vom JSON Format dekodieren + $engineStats = json_decode($engineStats, true); + + # Eine Sortierung wäre nicht das verkehrteste + uasort($engineStats["recent"], function ($a, $b) { + if ($a["requests"] == $b["requests"]) { + return 0; + } + + return ($a["requests"] < $b["requests"]) ? 1 : -1; + }); + + uasort($engineStats["overall"], function ($a, $b) { + if ($a["requests"] == $b["requests"]) { + return 0; + } + + return ($a["requests"] < $b["requests"]) ? 1 : -1; + }); + return view('admin.engines') + ->with('engineStats', $engineStats) + ->with('title', "Suchmaschinenstatus - MetaGer"); + } else { + return redirect(url('admin')); + } + } } diff --git a/app/Http/routes.php b/app/Http/routes.php index 04074ed73..96423a88f 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -144,6 +144,7 @@ Route::group( Route::get('admin', 'AdminInterface@index'); Route::get('admin/count', 'AdminInterface@count'); Route::get('admin/check', 'AdminInterface@check'); + Route::get('admin/engines', 'AdminInterface@engines'); Route::get('settings', 'StartpageController@loadSettings'); diff --git a/resources/views/admin/engines.blade.php b/resources/views/admin/engines.blade.php new file mode 100644 index 000000000..43ad731e9 --- /dev/null +++ b/resources/views/admin/engines.blade.php @@ -0,0 +1,54 @@ +@extends('layouts.subPages') + +@section('title', $title ) + +@section('content') +<h1>Suchmaschinenübersicht</h1> +<p>Diese Übersicht gibt Aufschluss darüber, welche Suchmaschinen wie oft abgefragt wurden und zusätzlich wie oft diese innerhalb unseres Timeouts geantwortet haben</p> +<table class="table table-bordered"> + <caption>Daten der letzten 10 Minuten</caption> + <thead> + <tr> + <th>Name</th> + <th>Anzahl der gesamten Abfragen</th> + <th>Davon tatsächlich beantwortet</th> + <th>Prozent</th> + </tr> + </thead> + <tbody> + @foreach($engineStats["recent"] as $name => $values) + @if($values["requests"] > 0) + <tr @if($values["requests"] === $values["answered"]) class="success" @else class="danger" @endif> + <td>{{$name}}</td> + <td>{{$values["requests"]}}</td> + <td>{{$values["answered"]}}</td> + <td>{{ floor(($values["answered"] / $values["requests"]) * 100) }}%</td> + </tr> + @endif + @endforeach + </tbody> +</table> +<table class="table table-bordered"> + <caption>Daten insgesamt</caption> + <thead> + <tr> + <th>Name</th> + <th>Anzahl der gesamten Abfragen</th> + <th>Davon tatsächlich beantwortet</th> + <th>Prozent</th> + </tr> + </thead> + <tbody> + @foreach($engineStats["overall"] as $name => $values) + @if($values["requests"] > 0) + <tr @if($values["requests"] === $values["answered"]) class="success" @else class="danger" @endif> + <td>{{$name}}</td> + <td>{{$values["requests"]}}</td> + <td>{{$values["answered"]}}</td> + <td>{{ floor(($values["answered"] / $values["requests"]) * 100) }}%</td> + </tr> + @endif + @endforeach + </tbody> +</table> +@endsection -- GitLab