Skip to content

Commit

Permalink
Add statistics for IS department
Browse files Browse the repository at this point in the history
  • Loading branch information
JanOppolzer committed Sep 14, 2023
1 parent c4e9338 commit f1d5ff0
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
40 changes: 40 additions & 0 deletions app/Http/Controllers/EduidczStatisticController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Http\Controllers;

use App\Models\Federation;
use Illuminate\Support\Facades\Cache;

class EduidczStatisticController extends Controller
{
public function __invoke()
{
$cache_time = now('Europe/Prague')->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'));
}
}
47 changes: 47 additions & 0 deletions resources/views/statistics.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>eduID.cz statistics</title>
<style>
table {
border: 1px solid black;
border-collapse: collapse;
}
table td {
border: 1px solid black;
padding: 3px;
}
</style>
</head>

<body>

<h1>Simple eduID.cz statistics</h1>

<table>
<tr>
<td>eduID.cz</td>
<td>{{ $eduidcz }}</td>
</tr>
<tr>
<td>eduGAIN</td>
<td>{{ $edugain }}</td>
</tr>
<tr>
<td>eduID.cz services</td>
<td>{{ $services }}</td>
</tr>
<tr>
<td>eduID.cz organizations</td>
<td>{{ $organizations }}</td>
</tr>
</table>

</body>

</html>
3 changes: 3 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');

0 comments on commit f1d5ff0

Please sign in to comment.