Compare commits

..

No commits in common. "bd30745e43685490c8c294996808aac2d9f979d7" and "5a0935b8f40cceb73d3d81578eed35d46f963ee1" have entirely different histories.

3 changed files with 3 additions and 49 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 city, country return country, city
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(city=k[0], country=k[1], count=v) dict(country=k[0], city=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,19 +4,7 @@
# Load Configuration from json # Load Configuration from json
############################################################################### ###############################################################################
# Require the configfile path as the first argument: CONFIG_FILE="folder_mount_config.json"
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

View File

@ -1,34 +0,0 @@
#!/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()