From f1d5ff0d25a880ad2f2418d9ef74a803392e8f8f Mon Sep 17 00:00:00 2001 From: Jan Oppolzer Date: Thu, 14 Sep 2023 11:19:35 +0200 Subject: [PATCH] Add statistics for IS department --- .../EduidczStatisticController.php | 40 ++++++++++++++++ resources/views/statistics.blade.php | 47 +++++++++++++++++++ routes/web.php | 3 ++ 3 files changed, 90 insertions(+) create mode 100644 app/Http/Controllers/EduidczStatisticController.php create mode 100644 resources/views/statistics.blade.php diff --git a/app/Http/Controllers/EduidczStatisticController.php b/app/Http/Controllers/EduidczStatisticController.php new file mode 100644 index 0000000..708a274 --- /dev/null +++ b/app/Http/Controllers/EduidczStatisticController.php @@ -0,0 +1,40 @@ +addHour(); + + $CACHE_TIME = Cache::remember('CACHE_TIME', $cache_time, function () use ($cache_time) { + return $cache_time; + }); + + $entities = Cache::remember('entities', $CACHE_TIME, function () { + return Federation::whereXml_name('https://eduid.cz/metadata') + ->first() + ->entities() + ->get() + ->filter(fn ($e) => ! $e->hfd); + }); + + // Number of non-HfD entities in eduID.cz + $eduidcz = $entities->count(); + + // Number of eduID.cz entities joined to eduGAIN + $edugain = $entities->filter(fn ($e) => $e->edugain)->count(); + + // Number of SPs in eduID.cz + $services = $entities->filter(fn ($e) => $e->type->value === 'sp')->count(); + + // Number of IdPs in eduID.cz + $organizations = $entities->filter(fn ($e) => $e->type->value === 'idp')->count(); + + return view('statistics', compact('eduidcz', 'edugain', 'services', 'organizations')); + } +} diff --git a/resources/views/statistics.blade.php b/resources/views/statistics.blade.php new file mode 100644 index 0000000..fbf8dd5 --- /dev/null +++ b/resources/views/statistics.blade.php @@ -0,0 +1,47 @@ + + + + + + + + eduID.cz statistics + + + + + +

Simple eduID.cz statistics

+ + + + + + + + + + + + + + + + + + +
eduID.cz{{ $eduidcz }}
eduGAIN{{ $edugain }}
eduID.cz services{{ $services }}
eduID.cz organizations{{ $organizations }}
+ + + + diff --git a/routes/web.php b/routes/web.php index 83d29db..1026cf5 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,6 +3,7 @@ use App\Http\Controllers\CategoryController; use App\Http\Controllers\CategoryManagementController; use App\Http\Controllers\DashboardController; +use App\Http\Controllers\EduidczStatisticController; use App\Http\Controllers\EntityController; use App\Http\Controllers\EntityFederationController; use App\Http\Controllers\EntityManagementController; @@ -112,6 +113,8 @@ Route::resource('memberships', MembershipController::class)->only('update', 'destroy'); +Route::get('statistics', EduidczStatisticController::class); + Route::get('login', [ShibbolethController::class, 'create'])->name('login')->middleware('guest'); Route::get('auth', [ShibbolethController::class, 'store'])->middleware('guest'); Route::get('logout', [ShibbolethController::class, 'destroy'])->name('logout')->middleware('auth');