starting full refactor with FastAPI routes + HTMX and AlpineJS on client side

This commit is contained in:
Lorenzo Venerandi
2026-02-17 13:09:01 +01:00
parent 04823dab63
commit 5d38ea45a8
34 changed files with 4517 additions and 2 deletions

View File

@@ -359,6 +359,16 @@ class DatabaseManager:
sanitized_ip = sanitize_ip(ip)
ip_stats = session.query(IpStats).filter(IpStats.ip == sanitized_ip).first()
if not ip_stats:
applogger.warning(
f"No IpStats record found for {sanitized_ip}, creating one."
)
now = datetime.now()
ip_stats = IpStats(
ip=sanitized_ip, total_requests=0, first_seen=now, last_seen=now
)
session.add(ip_stats)
# Check if category has changed and record it
old_category = ip_stats.category
if old_category != category:
@@ -390,6 +400,10 @@ class DatabaseManager:
sanitized_ip = sanitize_ip(ip)
ip_stats = session.query(IpStats).filter(IpStats.ip == sanitized_ip).first()
if not ip_stats:
applogger.warning(f"No IpStats record found for {sanitized_ip}")
return
# Record the manual category change
old_category = ip_stats.category
if old_category != category: