Compare commits

...

3 Commits

Author SHA1 Message Date
bd30745e43 fix language swap 2025-04-18 22:52:34 +00:00
02c5bc8026 Merge remote-tracking branch 'origin/development' 2025-04-18 22:04:35 +00:00
e9125098f8 path to config file as argument 2025-04-18 21:56:57 +00:00
3 changed files with 49 additions and 3 deletions

View File

@ -44,7 +44,7 @@ def lookup_location(ip):
response = geoReader.city(ip) response = geoReader.city(ip)
country = response.country.name if response.country.name else "Unknown" country = response.country.name if response.country.name else "Unknown"
city = response.city.name if response.city.name else "Unknown" city = response.city.name if response.city.name else "Unknown"
return country, city return city, country
except Exception: except Exception:
return "Unknown", "Unknown" return "Unknown", "Unknown"
@ -455,7 +455,7 @@ def dashboard():
location_data_dict[key] = location_data_dict.get(key, 0) + cnt location_data_dict[key] = location_data_dict.get(key, 0) + cnt
location_data = [ location_data = [
dict(country=k[0], city=k[1], count=v) dict(city=k[0], country=k[1], count=v)
for k, v in location_data_dict.items() for k, v in location_data_dict.items()
] ]
location_data.sort(key=lambda x: x['count'], reverse=True) location_data.sort(key=lambda x: x['count'], reverse=True)

View File

@ -4,7 +4,19 @@
# Load Configuration from json # Load Configuration from json
############################################################################### ###############################################################################
CONFIG_FILE="folder_mount_config.json" # Require the configfile path as the first argument:
CONFIG_FILE="$1"
if [[ -z "$CONFIG_FILE" ]]; then
echo "[ERROR] No path to config file given"
exit 1
fi
# Ensure the file actually exists:
if [[ ! -f "$CONFIG_FILE" ]]; then
echo "[ERROR] Config file '$CONFIG_FILE' not found."
exit 1
fi
# Ensure jq is installed before proceeding. # Ensure jq is installed before proceeding.
if ! command -v jq >/dev/null 2>&1; then if ! command -v jq >/dev/null 2>&1; then

34
swap_city_country.py Normal file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env python3
import sqlite3
# — CONFIGURE —
DB_NAME = 'access_log.db'
INDICATORS = [
"Germany",
"Canada",
"Paraguay",
"Uruguay",
"France",
"Australia",
"Ukraine",
"India"
]
# — END CONFIG —
# connect exactly as you use elsewhere
log_db = sqlite3.connect(DB_NAME, check_same_thread=False)
# build and run the swap
placeholders = ",".join("?" for _ in INDICATORS)
sql = f"""
UPDATE file_access_log
SET city = country,
country = city
WHERE city IN ({placeholders})
"""
cur = log_db.cursor()
cur.execute(sql, INDICATORS)
log_db.commit()
print(f"Swapped city↔country on {cur.rowcount} row{'s' if cur.rowcount!=1 else ''}.")
log_db.close()