diff --git a/analytics.py b/analytics.py index 82e87fd..63408af 100644 --- a/analytics.py +++ b/analytics.py @@ -179,24 +179,20 @@ def dashboard(): WHERE timestamp >= ? GROUP BY ip_address ORDER BY count DESC - LIMIT 20 + LIMIT 1000 ''', (start.isoformat(),)) ip_rows = cursor.fetchall() # Initialize GeoIP2 reader once for efficiency reader = geoip2.database.Reader('GeoLite2-City.mmdb') - ip_data = [] + location_data = [] for ip, count in ip_rows: country, city = lookup_location(ip, reader) - ip_data.append(dict(ip=ip, count=count, country=country, city=city)) + location_data.append(dict(count=count, country=country, city=city)) reader.close() - - # Aggregate by city (ignoring entries without a city) - city_counts = {} - for entry in ip_data: - if entry['city']: - city_counts[entry['city']] = city_counts.get(entry['city'], 0) + entry['count'] - city_data = [dict(city=city, count=count) for city, count in city_counts.items()] + # Sort by count in descending order and take the top 20 + location_data.sort(key=lambda x: x['count'], reverse=True) + location_data = location_data[:20] # Summary stats using separate SQL queries cursor.execute('SELECT COUNT(*) FROM file_access_log WHERE timestamp >= ?', (start.isoformat(),)) @@ -219,8 +215,7 @@ def dashboard(): top_files_data=top_files_data, user_agent_data=user_agent_data, referrer_data=referrer_data, - ip_data=ip_data, - city_data=city_data, + location_data=location_data, total_accesses=total_accesses, unique_files=unique_files, unique_ips=unique_ips) \ No newline at end of file diff --git a/templates/dashboard.html b/templates/dashboard.html index 769c757..242ef59 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -41,7 +41,7 @@
-
Total Accesses
+
Alle Downloads

{{ total_accesses }}

@@ -49,7 +49,7 @@
-
Unique Files
+
eindeutige Dateien

{{ unique_files }}

@@ -57,7 +57,7 @@
-
Unique IPs
+
eindeutige Nutzer

{{ unique_ips }}

@@ -70,7 +70,7 @@
-
Access Trend
+
Downloads
@@ -79,7 +79,7 @@
-
Top Files Accessed
+
Häufig geladene Dateien
@@ -88,7 +88,7 @@
-
User Agent Distribution
+
Verwendete Endgeräte
@@ -97,7 +97,7 @@
-
Referrer Distribution
+
Verteilung auf Ordner
@@ -107,58 +107,27 @@
- IP Address Access Distribution + Verteilung der Zugriffe
- - - - + + + - {% for ip in ip_data %} + {% for loc in location_data %} - - - - + + + {% else %} - - - {% endfor %} - -
IP AddressAccess CountCityCountryAnzahl DownloadsStadtLand
{{ ip.ip }}{{ ip.count }}{{ ip.city }}{{ ip.country }}{{ loc.count }}{{ loc.city }}{{ loc.country }}
No IP access data available for the selected timeframe.
-
-
- - -
-
- City Access Distribution -
-
- - - - - - - - - {% for city in city_data %} - - - - - {% else %} - - + {% endfor %} @@ -169,7 +138,7 @@
- Detailed File Access Data + Detailierte Dateizugriffe (Top 20)
CityAccess Count
{{ city.city }}{{ city.count }}
No city access data available for the selected timeframe.No access data available for the selected timeframe.
@@ -214,7 +183,7 @@ data: { labels: dailyAccessData.map(item => item.date), datasets: [{ - label: 'Access Count', + label: 'Download Count', data: dailyAccessData.map(item => item.count), borderWidth: 2, fill: true @@ -224,8 +193,8 @@ responsive: true, plugins: { legend: { position: 'top' } }, scales: { - x: { title: { display: true, text: 'Date' } }, - y: { title: { display: true, text: 'Access Count' } } + x: { title: { display: true, text: 'Datum' } }, + y: { title: { display: true, text: 'Download Count' } } } } }); @@ -237,7 +206,7 @@ data: { labels: topFilesData.map(item => item.full_path), datasets: [{ - label: 'Access Count', + label: 'Download Count', data: topFilesData.map(item => item.access_count), borderWidth: 1 }] @@ -247,8 +216,8 @@ responsive: true, plugins: { legend: { display: false } }, scales: { - x: { title: { display: true, text: 'Access Count' } }, - y: { title: { display: true, text: 'File Path' } } + x: { title: { display: true, text: 'Download Count' } }, + y: { title: { display: true, text: '' } } } } }); diff --git a/templates/index.html b/templates/index.html index 0b6a3ca..ad8b387 100644 --- a/templates/index.html +++ b/templates/index.html @@ -21,7 +21,7 @@
-
Bitte den Link aus der Telegram-Gruppe erneut anklicken.
+
Du hast keine gültigen Links im Speicher.
Bitte den Link aus der Telegram-Gruppe erneut anklicken.