From cba6b945082b97577104e97757a38dcf8c9d7eaa Mon Sep 17 00:00:00 2001 From: lelo Date: Mon, 15 Dec 2025 07:38:36 +0000 Subject: [PATCH] fix map --- analytics.py | 23 ++++++++++++++--------- app.py | 19 ++++++++++++------- templates/connections.html | 9 ++++++++- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/analytics.py b/analytics.py index 77c4dc7..785c9bf 100644 --- a/analytics.py +++ b/analytics.py @@ -191,15 +191,20 @@ def log_file_access(rel_path, filesize, mime, ip_address, user_agent, device_id, folder_yesterday.append({'date_str': yesterday_str, 'rel_path': folder_path}) # Finally, insert the new access at the top of the temp log + # Keep existing columns stable; append raw geo data for map use. file_access_temp.insert(0, [ - iso_ts, - rel_path, - filesize, - mime, - f"{city}, {country}", - user_agent, - device_id, - cached + iso_ts, # 0 timestamp + rel_path, # 1 path + filesize, # 2 size + mime, # 3 mime + f"{city}, {country}", # 4 location label + user_agent, # 5 UA + device_id, # 6 device + cached, # 7 cached flag + city, # 8 city + country, # 9 country + lat, # 10 latitude + lon # 11 longitude ]) return True @@ -814,4 +819,4 @@ if __name__ == "__main__": search="2025-06-13 Freitag 16 Uhr", replacement="2025-06-13 Eröffnungsgottesdienst Freitag 16 Uhr", dry_run=True - ) \ No newline at end of file + ) diff --git a/app.py b/app.py index 8f98b71..dc4ba64 100755 --- a/app.py +++ b/app.py @@ -703,17 +703,22 @@ def handle_request_initial_data(): @socketio.on('request_map_data') def handle_request_map_data(): - """Send initial map data with geographic coordinates""" - rows = a.return_file_access_with_geo() + """Send initial map data from in-memory log to avoid hitting the DB.""" + rows = a.return_file_access() connections = [] for row in rows: - if row[8] and row[9]: # lat and lon exist + # lat/lon are appended at indexes 10/11 in analytics.log_file_access + lat = row[10] if len(row) > 10 else None + lon = row[11] if len(row) > 11 else None + city = row[8] if len(row) > 8 else None + country = row[9] if len(row) > 9 else None + if lat and lon: connections.append({ 'timestamp': row[0], - 'city': row[4], - 'country': row[5], - 'lat': row[8], - 'lon': row[9] + 'city': city, + 'country': country, + 'lat': lat, + 'lon': lon }) emit('map_initial_data', {'connections': connections}) diff --git a/templates/connections.html b/templates/connections.html index 07cafb4..3f25712 100644 --- a/templates/connections.html +++ b/templates/connections.html @@ -18,6 +18,7 @@ display: flex; flex-direction: column; min-width: 0; + min-height: 0; } .table-section { flex: 1; @@ -27,7 +28,9 @@ } #map { width: 100%; - height: 100%; + flex: 1; + height: auto; + min-height: 320px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); } @@ -155,6 +158,10 @@