Added better dashboarding.

This commit is contained in:
2025-07-21 23:06:29 +02:00
parent 0c90fed0eb
commit d375f4ef38
10 changed files with 513 additions and 145 deletions

View File

@@ -1,12 +1,14 @@
# rstat_tool/dashboard.py
from flask import Flask, render_template
# --- FIX #1: Import the new function we need ---
from datetime import datetime, timedelta
from .database import (
get_overall_summary,
get_subreddit_summary,
get_all_scanned_subreddits,
get_deep_dive_details
get_deep_dive_details,
get_image_view_summary,
get_weekly_summary_for_subreddit
)
app = Flask(__name__, template_folder='../templates')
@@ -50,6 +52,35 @@ def deep_dive(symbol):
posts = get_deep_dive_details(symbol)
return render_template("deep_dive.html", posts=posts, symbol=symbol)
@app.route("/image/<name>")
def image_view(name):
"""The handler for the image-style dashboard."""
tickers = get_image_view_summary(name)
current_date = datetime.utcnow().strftime("%Y-%m-%d")
return render_template(
"image_view.html",
tickers=tickers,
subreddit_name=name,
current_date=current_date
)
@app.route("/image/weekly/<name>")
def weekly_image_view(name):
"""The handler for the WEEKLY image-style dashboard."""
tickers = get_weekly_summary_for_subreddit(name)
# Create the date range string for the title
end_date = datetime.utcnow()
start_date = end_date - timedelta(days=7)
date_range_str = f"{start_date.strftime('%b %d')} - {end_date.strftime('%b %d, %Y')}"
return render_template(
"weekly_image_view.html",
tickers=tickers,
subreddit_name=name,
date_range=date_range_str
)
def start_dashboard():
"""The main function called by the 'rstat-dashboard' command."""
print("Starting Flask server...")