Adds visitor dashboard and related features
This commit is contained in:
@@ -3,6 +3,7 @@ from datetime import datetime
|
||||
from sqlalchemy import (
|
||||
Column,
|
||||
DateTime,
|
||||
Float,
|
||||
Integer,
|
||||
LargeBinary,
|
||||
String,
|
||||
@@ -11,6 +12,7 @@ from sqlalchemy import (
|
||||
Date,
|
||||
ForeignKey,
|
||||
UniqueConstraint,
|
||||
Index,
|
||||
)
|
||||
from sqlalchemy.orm import DeclarativeBase, relationship
|
||||
|
||||
@@ -159,3 +161,47 @@ class StorageBlob(Base):
|
||||
size = Column(Integer, nullable=False)
|
||||
data = Column(LargeBinary, nullable=False)
|
||||
created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
|
||||
|
||||
|
||||
# ── Visitor Stats ──────────────────────────────────────────────
|
||||
|
||||
class VisitorStatDaily(Base):
|
||||
"""Daily aggregated visitor statistics."""
|
||||
__tablename__ = "visitor_stats_daily"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
date = Column(Date, nullable=False, unique=True)
|
||||
unique_visitors = Column(Integer, nullable=False, default=0)
|
||||
|
||||
__table_args__ = (
|
||||
Index("idx_visitor_stats_date", "date"),
|
||||
)
|
||||
|
||||
|
||||
class VisitorStatGeo(Base):
|
||||
"""Geographic breakdown of visitors per day."""
|
||||
__tablename__ = "visitor_stats_geo"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
date = Column(Date, nullable=False)
|
||||
country = Column(String(100), nullable=True)
|
||||
country_code = Column(String(10), nullable=True)
|
||||
city = Column(String(200), nullable=True)
|
||||
latitude = Column(Float, nullable=True)
|
||||
longitude = Column(Float, nullable=True)
|
||||
visitor_count = Column(Integer, nullable=False, default=0)
|
||||
|
||||
__table_args__ = (
|
||||
Index("idx_visitor_stats_geo_date", "date"),
|
||||
Index("idx_visitor_stats_geo_country", "country_code"),
|
||||
)
|
||||
|
||||
|
||||
class LogParseState(Base):
|
||||
"""Tracks the last successfully parsed log date."""
|
||||
__tablename__ = "log_parse_state"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
key = Column(String(20), unique=True, nullable=False, default="default")
|
||||
last_parsed_date = Column(Date, nullable=False)
|
||||
updated_at = Column(DateTime, nullable=False, default=datetime.utcnow)
|
||||
|
||||
Reference in New Issue
Block a user