diff --git a/analytics.py b/analytics.py index 51f3ab4..c4f46ef 100644 --- a/analytics.py +++ b/analytics.py @@ -328,6 +328,16 @@ def dashboard(): cursor = log_db.execute(query, params_for_filter) unique_user = cursor.fetchone()[0] + # Percentage of cached calls + query = f''' + SELECT (CAST(SUM(CASE WHEN cached = 1 THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*)) * 100 + FROM file_access_log + WHERE timestamp >= ? {filetype_filter_sql} + ''' + with log_db: + cursor = log_db.execute(query, params_for_filter) + cached_percentage = cursor.fetchone()[0] + # 8. Process location data with GeoIP2 reader = geoip2.database.Reader('GeoLite2-City.mmdb') location_data_dict = {} @@ -358,5 +368,6 @@ def dashboard(): total_accesses=total_accesses, unique_files=unique_files, unique_user=unique_user, + cached_percentage=f"{cached_percentage:.2f}", timeframe_data=timeframe_data ) diff --git a/templates/dashboard.html b/templates/dashboard.html index 933caca..2eac753 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -38,7 +38,7 @@
-
+
Alle Downloads
@@ -46,7 +46,7 @@
-
+
eindeutige Dateien
@@ -54,7 +54,7 @@
-
+
eindeutige Nutzer
@@ -62,6 +62,14 @@
+
+
+
+
beschleunigte Downloads
+

{{ cached_percentage }} %

+
+
+
@@ -171,7 +179,6 @@