diff --git a/analytics.py b/analytics.py index 24981fe..51f3ab4 100644 --- a/analytics.py +++ b/analytics.py @@ -95,7 +95,7 @@ def connections(): @require_secret def dashboard(): filetype_arg = request.args.get('filetype', 'audio') - timeframe = request.args.get('timeframe', 'today') + timeframe = request.args.get('timeframe', 'last24hours') now = datetime.now() # Determine which file type we're filtering by. @@ -114,8 +114,8 @@ def dashboard(): filetype = 'video/' # Determine start time based on timeframe - if timeframe == 'today': - start_dt = now.replace(hour=0, minute=0, second=0, microsecond=0) + if timeframe == 'last24hours': + start_dt = now - timedelta(hours=24) elif timeframe == '7days': start_dt = now - timedelta(days=7) elif timeframe == '30days': @@ -123,7 +123,7 @@ def dashboard(): elif timeframe == '365days': start_dt = now - timedelta(days=365) else: - start_dt = now.replace(hour=0, minute=0, second=0, microsecond=0) + start_dt = now - timedelta(hours=24) # We'll compare the textual timestamp (ISO 8601). start_str = start_dt.isoformat() @@ -157,7 +157,7 @@ def dashboard(): # 2. Distinct device trend # We'll group by hour if "today", by day if "7days"/"30days", by month if "365days" - if timeframe == 'today': + if timeframe == 'last24hours': # Group by hour: substr(timestamp, 12, 2) -> HH query = f''' SELECT substr(timestamp, 12, 2) AS bucket, COUNT(DISTINCT device_id) AS count @@ -202,7 +202,7 @@ def dashboard(): # 3. Timeframe-based aggregation # We'll group by hour if "today", by day if "7days"/"30days", by month if "365days". - if timeframe == 'today': + if timeframe == 'last24hours': # Hour: substr(timestamp, 12, 2) -> HH query = f''' SELECT substr(timestamp, 12, 2) AS bucket, COUNT(*) AS count diff --git a/templates/dashboard.html b/templates/dashboard.html index 7dee0bd..933caca 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -30,7 +30,7 @@ Auswertung