Refactored and redesigned dashboards.

This commit is contained in:
2025-07-25 22:38:38 +02:00
parent 44fc3ef533
commit 0dab12eb8c
11 changed files with 312 additions and 565 deletions

View File

@@ -61,13 +61,13 @@ if __name__ == "__main__":
# Determine the correct URL path and filename based on arguments
if args.subreddit:
view_type = "weekly" if args.weekly else "daily"
url_path_to_render = f"image/{view_type}/{args.subreddit}"
# Add ?view=... and the new &image=true parameter
url_path_to_render = f"subreddit/{args.subreddit}?view={view_type}&image=true"
filename_prefix_to_save = f"{args.subreddit}_{view_type}"
export_image(url_path_to_render, filename_prefix_to_save)
elif args.overall:
if args.weekly:
print("Warning: --weekly flag has no effect with --overall. Exporting overall summary.")
url_path_to_render = "image/overall"
filename_prefix_to_save = "overall_summary"
# For overall, we assume daily view for the image
url_path_to_render = "/?view=daily&image=true"
filename_prefix_to_save = "overall_summary_daily"
export_image(url_path_to_render, filename_prefix_to_save)

View File

@@ -4,13 +4,12 @@ from flask import Flask, render_template, request
from datetime import datetime, timedelta, timezone
from .logger_setup import logger as log
from .database import (
get_overall_summary,
get_subreddit_summary,
get_all_scanned_subreddits,
get_deep_dive_details,
get_daily_summary_for_subreddit,
get_weekly_summary_for_subreddit,
get_overall_image_view_summary
get_overall_daily_summary, # Now correctly imported
get_overall_weekly_summary # Now correctly imported
)
app = Flask(__name__, template_folder='../templates')
@@ -31,21 +30,64 @@ def format_market_cap(mc):
@app.context_processor
def inject_subreddits():
"""Makes the list of all scanned subreddits available to every template."""
subreddits = get_all_scanned_subreddits()
return dict(subreddits=subreddits)
"""Makes the list of all subreddits available to every template for the navbar."""
return dict(all_subreddits=get_all_scanned_subreddits())
@app.route("/")
def index():
"""The handler for the main dashboard page."""
tickers = get_overall_summary(limit=10)
return render_template("index.html", tickers=tickers)
def overall_dashboard():
"""Handler for the main, overall dashboard."""
view_type = request.args.get('view', 'daily')
is_image_mode = request.args.get('image') == 'true'
if view_type == 'weekly':
tickers, start, end = get_overall_weekly_summary()
date_string = f"{start.strftime('%b %d')} - {end.strftime('%b %d, %Y')}"
subtitle = "All Subreddits - Top 10 Weekly"
else: # Default to daily
tickers = get_overall_daily_summary()
date_string = datetime.now(timezone.utc).strftime("%Y-%m-%d")
subtitle = "All Subreddits - Top 10 Daily"
return render_template(
"dashboard_view.html",
title="Overall Dashboard",
subtitle=subtitle,
date_string=date_string,
tickers=tickers,
view_type=view_type,
subreddit_name=None,
is_image_mode=is_image_mode
)
@app.route("/subreddit/<name>")
def subreddit_dashboard(name):
"""A dynamic route for per-subreddit dashboards."""
tickers = get_subreddit_summary(name, limit=10)
return render_template("subreddit.html", tickers=tickers, subreddit_name=name)
"""Handler for per-subreddit dashboards."""
view_type = request.args.get('view', 'daily')
is_image_mode = request.args.get('image') == 'true'
if view_type == 'weekly':
today = datetime.now(timezone.utc)
target_date = today - timedelta(days=7) # Default to last week
tickers, start, end = get_weekly_summary_for_subreddit(name, target_date)
date_string = f"{start.strftime('%b %d')} - {end.strftime('%b %d, %Y')}"
subtitle = f"r/{name} - Top 10 Weekly"
else: # Default to daily
tickers = get_daily_summary_for_subreddit(name)
date_string = datetime.now(timezone.utc).strftime("%Y-%m-%d")
subtitle = f"r/{name} - Top 10 Daily"
return render_template(
"dashboard_view.html",
title=f"r/{name} Dashboard",
subtitle=subtitle,
date_string=date_string,
tickers=tickers,
view_type=view_type,
subreddit_name=name,
is_image_mode=is_image_mode
)
@app.route("/deep-dive/<symbol>")
def deep_dive(symbol):
@@ -54,63 +96,6 @@ def deep_dive(symbol):
posts = get_deep_dive_details(symbol)
return render_template("deep_dive.html", posts=posts, symbol=symbol)
@app.route("/image/daily/<name>")
def daily_image_view(name):
"""The handler for the image-style dashboard."""
tickers = get_daily_summary_for_subreddit(name)
current_date = datetime.now(timezone.utc).strftime("%Y-%m-%d")
return render_template(
"daily_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.
Accepts an optional 'date' query parameter in YYYY-MM-DD format.
"""
# Get the date from the URL query string, e.g., ?date=2025-07-21
date_str = request.args.get('date')
target_date = None
if date_str:
try:
# Convert the string to a datetime object
target_date = datetime.strptime(date_str, "%Y-%m-%d").replace(tzinfo=timezone.utc)
except ValueError:
return "Invalid date format. Please use YYYY-MM-DD.", 400
else:
# If no date is provided, default to showing LAST week
today = datetime.now(timezone.utc)
target_date = today - timedelta(days=7)
# The query now returns the results and the date objects used
tickers, start_of_week, end_of_week = get_weekly_summary_for_subreddit(name, target_date)
# Format the date range for the title
date_range_str = f"{start_of_week.strftime('%b %d')} - {end_of_week.strftime('%b %d, %Y')}"
return render_template(
"weekly_image_view.html",
tickers=tickers,
subreddit_name=name,
date_range=date_range_str
)
@app.route("/image/overall")
def overall_image_view():
"""The handler for the overall image-style dashboard."""
tickers = get_overall_image_view_summary()
current_date = datetime.now(timezone.utc).strftime("%Y-%m-%d")
return render_template(
"overall_image_view.html",
tickers=tickers,
current_date=current_date
)
def start_dashboard():
"""The main function called by the 'rstat-dashboard' command."""
log.info("Starting Flask server...")

View File

@@ -311,6 +311,49 @@ def get_overall_image_view_summary():
conn.close()
return results
def get_overall_daily_summary():
"""
Gets the top tickers across all subreddits from the LAST 24 HOURS.
(This is a copy of get_overall_summary, renamed for clarity).
"""
conn = get_db_connection()
one_day_ago = datetime.now(timezone.utc) - timedelta(days=1)
one_day_ago_timestamp = int(one_day_ago.timestamp())
query = """
SELECT t.symbol, t.market_cap, t.closing_price, COUNT(m.id) as total_mentions,
SUM(CASE WHEN m.mention_sentiment > 0.1 THEN 1 ELSE 0 END) as bullish_mentions,
SUM(CASE WHEN m.mention_sentiment < -0.1 THEN 1 ELSE 0 END) as bearish_mentions
FROM mentions m JOIN tickers t ON m.ticker_id = t.id
WHERE m.mention_timestamp >= ?
GROUP BY t.symbol, t.market_cap, t.closing_price
ORDER BY total_mentions DESC LIMIT 10;
"""
results = conn.execute(query, (one_day_ago_timestamp,)).fetchall()
conn.close()
return results
def get_overall_weekly_summary():
"""
Gets the top tickers across all subreddits for the LAST 7 DAYS.
"""
conn = get_db_connection()
today = datetime.now(timezone.utc)
start_of_week, end_of_week = get_week_start_end(today - timedelta(days=7)) # Get last week's boundaries
start_timestamp = int(start_of_week.timestamp())
end_timestamp = int(end_of_week.timestamp())
query = """
SELECT t.symbol, t.market_cap, t.closing_price, COUNT(m.id) as total_mentions,
SUM(CASE WHEN m.mention_sentiment > 0.1 THEN 1 ELSE 0 END) as bullish_mentions,
SUM(CASE WHEN m.mention_sentiment < -0.1 THEN 1 ELSE 0 END) as bearish_mentions
FROM mentions m JOIN tickers t ON m.ticker_id = t.id
WHERE m.mention_timestamp BETWEEN ? AND ?
GROUP BY t.symbol, t.market_cap, t.closing_price
ORDER BY total_mentions DESC LIMIT 10;
"""
results = conn.execute(query, (start_timestamp, end_timestamp)).fetchall()
conn.close()
return results, start_of_week, end_of_week
def get_deep_dive_details(ticker_symbol):
""" Gets all analyzed posts that mention a specific ticker. """
conn = get_db_connection()

View File

@@ -1,109 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}Reddit Stock Dashboard{% endblock %}</title>
<style>
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
background-color: #f4f7f6;
color: #333;
margin: 0;
line-height: 1.6;
}
.navbar {
background-color: #ffffff;
padding: 1rem 2rem;
border-bottom: 1px solid #e0e0e0;
display: flex;
flex-wrap: wrap;
gap: 1rem;
}
.navbar a {
color: #555;
text-decoration: none;
font-weight: 600;
padding: 0.5rem 1rem;
border-radius: 6px;
transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}
.navbar a:hover {
background-color: #e9ecef;
color: #000;
}
.container {
max-width: 1000px;
margin: 2rem auto;
padding: 2rem;
background-color: #ffffff;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
h1 {
font-size: 1.75rem;
font-weight: 700;
margin-top: 0;
border-bottom: 1px solid #eee;
padding-bottom: 0.5rem;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 2rem;
font-size: 0.95rem;
}
th, td {
padding: 1rem;
text-align: left;
border-bottom: 1px solid #e0e0e0;
}
th {
font-weight: 600;
text-transform: uppercase;
font-size: 0.8rem;
letter-spacing: 0.05em;
color: #666;
}
tr:last-child td {
border-bottom: none;
}
.sentiment-bullish { color: #28a745; font-weight: 600; }
.sentiment-bearish { color: #dc3545; font-weight: 600; }
.sentiment-neutral { color: #6c757d; }
.post-card {
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 1.5rem;
margin-bottom: 1.5rem;
}
.post-card h3 {
margin-top: 0;
font-size: 1.2rem;
}
.post-card h3 a {
color: #0056b3;
text-decoration: none;
}
.post-card h3 a:hover {
text-decoration: underline;
}
.post-meta {
font-size: 0.9rem;
color: #666;
}
</style>
</head>
<body>
<header class="navbar">
<a href="/">Overall</a>
{% for sub in subreddits %}
<a href="/subreddit/{{ sub }}">r/{{ sub }}</a>
{% endfor %}
</header>
<main class="container">
{% block content %}{% endblock %}
</main>
</body>
</html>

View File

@@ -1,95 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>r/{{ subreddit_name }} Ticker Mentions</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap" rel="stylesheet">
<style>
body { margin: 0; padding: 2rem; font-family: 'Inter', sans-serif; background: #1a1a1a; display: flex; justify-content: center; align-items: center; min-height: 100vh; }
.image-container { width: 750px; background: linear-gradient(145deg, #2d3748, #1a202c); color: #ffffff; border-radius: 16px; padding: 2.5rem; box-shadow: 0 10px 30px rgba(0,0,0,0.5); text-align: center; }
header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 2rem; }
.title-block { text-align: left; }
.title-block h1 { font-size: 2.5rem; font-weight: 800; margin: 0; line-height: 1; }
.title-block h2 { font-size: 1.25rem; font-weight: 600; margin: 0.5rem 0 0; color: #a0aec0; }
.date { font-size: 1.1rem; font-weight: 600; color: #a0aec0; letter-spacing: 0.02em; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 1rem 0.5rem; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
th { font-weight: 700; text-transform: uppercase; font-size: 0.75rem; color: #718096; letter-spacing: 0.05em; }
td { font-size: 1.1rem; font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.rank { font-weight: 700; color: #cbd5e0; width: 5%; }
td.ticker { width: 15%; }
td.financials { text-align: right; width: 20%; }
td.mentions { text-align: center; width: 15%; }
td.sentiment { text-align: center; width: 20%; }
th.mentions, th.sentiment {
text-align: center;
}
th.financials {
text-align: right;
}
.sentiment-bullish { color: #48bb78; font-weight: 700; }
.sentiment-bearish { color: #f56565; font-weight: 700; }
.sentiment-neutral { color: #a0aec0; font-weight: 600; }
footer { margin-top: 2.5rem; }
.brand-name { font-size: 1.75rem; font-weight: 800; letter-spacing: -1px; }
.brand-subtitle { font-size: 1rem; color: #a0aec0; }
</style>
</head>
<body>
<div class="image-container">
<header>
<div class="title-block">
<h1>Ticker Mentions Daily</h1>
<h2>r/{{ subreddit_name }}</h2>
</div>
<div class="date">{{ current_date }}</div>
</header>
<table>
<thead>
<tr>
<th class="rank">Rank</th>
<th class="ticker">Ticker</th>
<th class="mentions">Mentions</th>
<th class="financials">Mkt Cap</th>
<th class="financials">Close Price</th>
<th class="sentiment">Sentiment</th>
</tr>
</thead>
<tbody>
{% for ticker in tickers %}
<tr>
<td class="rank">{{ loop.index }}</td>
<td class="ticker">{{ ticker.symbol }}</td>
<td class="mentions">{{ ticker.total_mentions }}</td>
<td class="financials">{{ ticker.market_cap | format_mc }}</td>
<td class="financials">
{% if ticker.closing_price %}
${{ "%.2f"|format(ticker.closing_price) }}
{% else %}
N/A
{% endif %}
</td>
<td class="sentiment">
{% if ticker.bullish_mentions > ticker.bearish_mentions %}
<span class="sentiment-bullish">Bullish</span>
{% elif ticker.bearish_mentions > ticker.bullish_mentions %}
<span class="sentiment-bearish">Bearish</span>
{% else %}
<span class="sentiment-neutral">Neutral</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<footer>
<div class="brand-name">r/rstat</div>
<div class="brand-subtitle">visit us for more</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,140 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}RSTAT Dashboard{% endblock %}</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap" rel="stylesheet">
<style>
body { margin: 0; padding: 2rem; font-family: 'Inter', sans-serif; background: #1a1a1a; display: flex; flex-direction: column; align-items: center; min-height: 100vh; }
.navbar { width: 100%; max-width: 1200px; background-color: rgba(45, 55, 72, 0.5); padding: 1rem 2rem; border-radius: 12px; margin-bottom: 2rem; display: flex; flex-wrap: wrap; gap: 1rem; align-items: center;}
.navbar a { color: #cbd5e0; text-decoration: none; font-weight: 600; padding: 0.5rem 1rem; border-radius: 6px; transition: background-color 0.2s, color 0.2s; }
.navbar a.active, .navbar a:hover { background-color: #4a5568; color: #ffffff; }
.view-switcher { margin-left: auto; display: flex; gap: 0.5rem; }
.dropdown {
position: relative; /* Establishes a positioning context for the menu */
display: inline-block;
}
.dropdown {
position: relative;
display: inline-block;
/* Remove the padding that was causing the misalignment */
/* padding-bottom: 0.5rem; */
}
.dropdown-button {
color: #cbd5e0;
font-weight: 600;
padding: 0.5rem 1rem;
border-radius: 6px;
cursor: pointer;
transition: background-color 0.2s, color 0.2s;
display: block; /* Ensures it behaves predictably with padding */
}
.dropdown-button.active, .dropdown:hover .dropdown-button {
background-color: #4a5568;
color: #ffffff;
}
.dropdown-menu {
visibility: hidden;
opacity: 0;
position: absolute;
background-color: #2d3748;
min-width: 200px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.4);
z-index: 1;
border-radius: 8px;
padding: 0.5rem 0;
/* Use 'top: 100%' to position it right below the container, plus a small gap */
top: calc(100% + 0.25rem);
left: 0;
transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
}
.dropdown-menu a {
color: #e2e8f0;
padding: 0.75rem 1.5rem;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-menu a:hover {
background-color: #4a5568;
}
.dropdown:hover .dropdown-menu {
visibility: visible;
opacity: 1;
}
.image-container { width: 750px; background: linear-gradient(145deg, #2d3748, #1a202c); color: #ffffff; border-radius: 16px; padding: 2.5rem; box-shadow: 0 10px 30px rgba(0,0,0,0.5); text-align: center; }
header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 2rem; }
.title-block { text-align: left; }
.title-block h1 { font-size: 2.5rem; font-weight: 800; margin: 0; line-height: 1; }
.title-block h2 { font-size: 1.25rem; font-weight: 600; margin: 0.5rem 0 0; color: #a0aec0; }
.date { font-size: 1.1rem; font-weight: 600; color: #a0aec0; letter-spacing: 0.02em; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 1rem 0.5rem; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
th { font-weight: 700; text-transform: uppercase; font-size: 0.75rem; color: #718096; letter-spacing: 0.05em; }
th.mentions, th.sentiment { text-align: center; }
th.financials { text-align: right; }
td { font-size: 1.1rem; font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.rank { font-weight: 700; color: #cbd5e0; width: 5%; }
td.ticker { width: 15%; }
td.financials { text-align: right; width: 20%; }
td.mentions { text-align: center; width: 15%; }
td.sentiment { text-align: center; width: 20%; }
.sentiment-bullish { color: #48bb78; font-weight: 700; }
.sentiment-bearish { color: #f56565; font-weight: 700; }
.sentiment-neutral { color: #a0aec0; font-weight: 600; }
footer { margin-top: 2.5rem; }
.brand-name { font-size: 1.75rem; font-weight: 800; letter-spacing: -1px; }
.brand-subtitle { font-size: 1rem; color: #a0aec0; }
/* Style for the ticker link in interactive mode */
td.ticker a {
color: inherit; /* Make the link color the same as the text */
text-decoration: none;
display: inline-block;
transition: transform 0.1s ease-in-out;
}
td.ticker a:hover {
text-decoration: underline;
transform: scale(1.05);
}
/* Ticker coloring (used in both modes) */
tr:nth-child(1) td.ticker { color: #d8b4fe; } tr:nth-child(6) td.ticker { color: #fca5a5; }
tr:nth-child(2) td.ticker { color: #a3e635; } tr:nth-child(7) td.ticker { color: #fdba74; }
tr:nth-child(3) td.ticker { color: #67e8f9; } tr:nth-child(8) td.ticker { color: #6ee7b7; }
tr:nth-child(4) td.ticker { color: #fde047; } tr:nth-child(9) td.ticker { color: #93c5fd; }
tr:nth-child(5) td.ticker { color: #fcd34d; } tr:nth-child(10) td.ticker { color: #d1d5db; }
</style>
</head>
<body>
{% if not is_image_mode %}
<nav class="navbar">
<a href="/" {% if not subreddit_name %}class="active"{% endif %}>Overall</a>
<!-- --- THIS IS THE NEW HTML STRUCTURE FOR THE DROPDOWN --- -->
<div class="dropdown">
<div class="dropdown-button {% if subreddit_name %}active{% endif %}">
Subreddits ▼
</div>
<div class="dropdown-menu">
{% for sub in all_subreddits %}
<a href="/subreddit/{{ sub }}">{{ sub }}</a>
{% endfor %}
</div>
</div>
<!-- --- END OF NEW HTML STRUCTURE --- -->
<div class="view-switcher">
<a href="?view=daily" {% if view_type == 'daily' %}class="active"{% endif %}>Daily</a>
<a href="?view=weekly" {% if view_type == 'weekly' %}class="active"{% endif %}>Weekly</a>
</div>
</nav>
{% endif %}
<main>
{% block content %}{% endblock %}
</main>
</body>
</html>

View File

@@ -0,0 +1,69 @@
{% extends "dashboard_base.html" %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
<div class="image-container">
<header>
<div class="title-block">
<h1>Reddit Ticker Mentions</h1>
<h2>{{ subtitle }}</h2>
</div>
<div class="date">{{ date_string }}</div>
</header>
<table>
<thead>
<tr>
<th class="rank">Rank</th>
<th class="ticker">Ticker</th>
<th class="mentions">Mentions</th>
<th class="sentiment">Sentiment</th>
<th class="financials">Mkt Cap</th>
<th class="financials">Close Price</th>
</tr>
</thead>
<tbody>
{% for ticker in tickers %}
<tr>
<td class="rank">{{ loop.index }}</td>
<td class="ticker">
<strong>
{% if is_image_mode %}
{{ ticker.symbol }}
{% else %}
<a href="/deep-dive/{{ ticker.symbol }}">{{ ticker.symbol }}</a>
{% endif %}
</strong>
</td>
<td class="mentions">{{ ticker.total_mentions }}</td>
<td class="sentiment">
{% if ticker.bullish_mentions > ticker.bearish_mentions %}
<span class="sentiment-bullish">Bullish</span>
{% elif ticker.bearish_mentions > ticker.bullish_mentions %}
<span class="sentiment-bearish">Bearish</span>
{% else %}
<span class="sentiment-neutral">Neutral</span>
{% endif %}
</td>
<td class="financials">{{ ticker.market_cap | format_mc }}</td>
<td class="financials">
{% if ticker.closing_price %}
${{ "%.2f"|format(ticker.closing_price) }}
{% else %}
N/A
{% endif %}
</td>
</tr>
{% else %}
<tr>
<td colspan="6" style="text-align: center; padding: 2rem;">No ticker data found for this period.</td>
</tr>
{% endfor %}
</tbody>
</table>
<footer>
<div class="brand-name">RSTAT</div>
<div class="brand-subtitle">Reddit Stock Analysis Tool</div>
</footer>
</div>
{% endblock %}

View File

@@ -1,48 +0,0 @@
{% extends "base.html" %}
{% block title %}Overall Dashboard{% endblock %}
{% block content %}
<h1>
Top 10 Tickers Today (All Subreddits)
<!-- ADD THIS LINK -->
<a href="/image/overall" target="_blank" style="font-size: 0.8rem; margin-left: 1rem; font-weight: normal;">image</a>
</h1>
<table>
<thead>
<tr>
<th>Ticker</th>
<th>Mentions</th>
<th>Market Cap</th>
<th>Closing Price</th>
<th>Sentiment</th>
</tr>
</thead>
<tbody>
{% for ticker in tickers %}
<tr>
<td><strong><a href="/deep-dive/{{ ticker.symbol }}">{{ ticker.symbol }}</a></strong></td>
<td>{{ ticker.mention_count }}</td>
<td>{{ ticker.market_cap | format_mc }}</td>
<!-- NEW COLUMN FOR CLOSING PRICE -->
<td>
{% if ticker.closing_price %}
${{ "%.2f"|format(ticker.closing_price) }}
{% else %}
N/A
{% endif %}
</td>
<td>
{% if ticker.bullish_mentions > ticker.bearish_mentions %}
<span class="sentiment-bullish">Bullish</span>
{% elif ticker.bearish_mentions > ticker.bullish_mentions %}
<span class="sentiment-bearish">Bearish</span>
{% else %}
<span class="sentiment-neutral">Neutral</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@@ -1,95 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>r/{{ subreddit_name }} Ticker Mentions</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap" rel="stylesheet">
<style>
body { margin: 0; padding: 2rem; font-family: 'Inter', sans-serif; background: #1a1a1a; display: flex; justify-content: center; align-items: center; min-height: 100vh; }
.image-container { width: 750px; background: linear-gradient(145deg, #2d3748, #1a202c); color: #ffffff; border-radius: 16px; padding: 2.5rem; box-shadow: 0 10px 30px rgba(0,0,0,0.5); text-align: center; }
header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 2rem; }
.title-block { text-align: left; }
.title-block h1 { font-size: 2.5rem; font-weight: 800; margin: 0; line-height: 1; }
.title-block h2 { font-size: 1.25rem; font-weight: 600; margin: 0.5rem 0 0; color: #a0aec0; }
.date { font-size: 1.1rem; font-weight: 600; color: #a0aec0; letter-spacing: 0.02em; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 1rem 0.5rem; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
th { font-weight: 700; text-transform: uppercase; font-size: 0.75rem; color: #718096; letter-spacing: 0.05em; }
td { font-size: 1.1rem; font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.rank { font-weight: 700; color: #cbd5e0; width: 5%; }
td.ticker { width: 15%; }
td.financials { text-align: right; width: 20%; }
td.mentions { text-align: center; width: 15%; }
td.sentiment { text-align: center; width: 20%; }
th.mentions, th.sentiment {
text-align: center;
}
th.financials {
text-align: right;
}
.sentiment-bullish { color: #48bb78; font-weight: 700; }
.sentiment-bearish { color: #f56565; font-weight: 700; }
.sentiment-neutral { color: #a0aec0; font-weight: 600; }
footer { margin-top: 2.5rem; }
.brand-name { font-size: 1.75rem; font-weight: 800; letter-spacing: -1px; }
.brand-subtitle { font-size: 1rem; color: #a0aec0; }
</style>
</head>
<body>
<div class="image-container">
<header>
<div class="title-block">
<h1>Ticker Mentions Daily</h1>
<h2>All Subreddits</h2>
</div>
<div class="date">{{ current_date }}</div>
</header>
<table>
<thead>
<tr>
<th class="rank">Rank</th>
<th class="ticker">Ticker</th>
<th class="mentions">Mentions</th>
<th class="financials">Mkt Cap</th>
<th class="financials">Close Price</th>
<th class="sentiment">Sentiment</th>
</tr>
</thead>
<tbody>
{% for ticker in tickers %}
<tr>
<td class="rank">{{ loop.index }}</td>
<td class="ticker">{{ ticker.symbol }}</td>
<td class="mentions">{{ ticker.total_mentions }}</td>
<td class="financials">{{ ticker.market_cap | format_mc }}</td>
<td class="financials">
{% if ticker.closing_price %}
${{ "%.2f"|format(ticker.closing_price) }}
{% else %}
N/A
{% endif %}
</td>
<td class="sentiment">
{% if ticker.bullish_mentions > ticker.bearish_mentions %}
<span class="sentiment-bullish">Bullish</span>
{% elif ticker.bearish_mentions > ticker.bullish_mentions %}
<span class="sentiment-bearish">Bearish</span>
{% else %}
<span class="sentiment-neutral">Neutral</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<footer>
<div class="brand-name">r/rstat</div>
<div class="brand-subtitle">visit us for more</div>
</footer>
</div>
</body>
</html>

View File

@@ -1,48 +0,0 @@
{% extends "base.html" %}
{% block title %}r/{{ subreddit_name }} Dashboard{% endblock %}
{% block content %}
<h1>
Top 10 Tickers Today in r/{{ subreddit_name }}
<a href="/image/daily/{{ subreddit_name }}" target="_blank" style="font-size: 0.8rem; margin-left: 1rem; font-weight: normal;">daily image</a>
<a href="/image/weekly/{{ subreddit_name }}" target="_blank" style="font-size: 0.8rem; margin-left: 1rem; font-weight: normal;">weekly image</a>
</h1>
<table>
<thead>
<tr>
<th>Ticker</th>
<th>Mentions</th>
<th>Market Cap</th>
<th>Closing Price</th>
<th>Sentiment</th>
</tr>
</thead>
<tbody>
{% for ticker in tickers %}
<tr>
<td><strong><a href="/deep-dive/{{ ticker.symbol }}">{{ ticker.symbol }}</a></strong></td>
<td>{{ ticker.mention_count }}</td>
<td>{{ ticker.market_cap | format_mc }}</td>
<!-- NEW COLUMN FOR CLOSING PRICE -->
<td>
{% if ticker.closing_price %}
${{ "%.2f"|format(ticker.closing_price) }}
{% else %}
N/A
{% endif %}
</td>
<td>
{% if ticker.bullish_mentions > ticker.bearish_mentions %}
<span class="sentiment-bullish">Bullish</span>
{% elif ticker.bearish_mentions > ticker.bullish_mentions %}
<span class="sentiment-bearish">Bearish</span>
{% else %}
<span class="sentiment-neutral">Neutral</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@@ -1,95 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>r/{{ subreddit_name }} Ticker Mentions</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap" rel="stylesheet">
<style>
body { margin: 0; padding: 2rem; font-family: 'Inter', sans-serif; background: #1a1a1a; display: flex; justify-content: center; align-items: center; min-height: 100vh; }
.image-container { width: 750px; background: linear-gradient(145deg, #2d3748, #1a202c); color: #ffffff; border-radius: 16px; padding: 2.5rem; box-shadow: 0 10px 30px rgba(0,0,0,0.5); text-align: center; }
header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 2rem; }
.title-block { text-align: left; }
.title-block h1 { font-size: 2.5rem; font-weight: 800; margin: 0; line-height: 1; }
.title-block h2 { font-size: 1.25rem; font-weight: 600; margin: 0.5rem 0 0; color: #a0aec0; }
.date { font-size: 1.1rem; font-weight: 600; color: #a0aec0; letter-spacing: 0.02em; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 1rem 0.5rem; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
th { font-weight: 700; text-transform: uppercase; font-size: 0.75rem; color: #718096; letter-spacing: 0.05em; }
td { font-size: 1.1rem; font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.rank { font-weight: 700; color: #cbd5e0; width: 5%; }
td.ticker { width: 15%; }
td.financials { text-align: right; width: 20%; }
td.mentions { text-align: center; width: 15%; }
td.sentiment { text-align: center; width: 20%; }
th.mentions, th.sentiment {
text-align: center;
}
th.financials {
text-align: right;
}
.sentiment-bullish { color: #48bb78; font-weight: 700; }
.sentiment-bearish { color: #f56565; font-weight: 700; }
.sentiment-neutral { color: #a0aec0; font-weight: 600; }
footer { margin-top: 2.5rem; }
.brand-name { font-size: 1.75rem; font-weight: 800; letter-spacing: -1px; }
.brand-subtitle { font-size: 1rem; color: #a0aec0; }
</style>
</head>
<body>
<div class="image-container">
<header>
<div class="title-block">
<h1>Ticker Mentions Weekly</h1>
<h2>r/{{ subreddit_name }}</h2>
</div>
<div class="date">{{ date_range }}</div>
</header>
<table>
<thead>
<tr>
<th class="rank">Rank</th>
<th class="ticker">Ticker</th>
<th class="mentions">Mentions</th>
<th class="financials">Mkt Cap</th>
<th class="financials">Close Price</th>
<th class="sentiment">Sentiment</th>
</tr>
</thead>
<tbody>
{% for ticker in tickers %}
<tr>
<td class="rank">{{ loop.index }}</td>
<td class="ticker">{{ ticker.symbol }}</td>
<td class="mentions">{{ ticker.total_mentions }}</td>
<td class="financials">{{ ticker.market_cap | format_mc }}</td>
<td class="financials">
{% if ticker.closing_price %}
${{ "%.2f"|format(ticker.closing_price) }}
{% else %}
N/A
{% endif %}
</td>
<td class="sentiment">
{% if ticker.bullish_mentions > ticker.bearish_mentions %}
<span class="sentiment-bullish">Bullish</span>
{% elif ticker.bearish_mentions > ticker.bullish_mentions %}
<span class="sentiment-bearish">Bearish</span>
{% else %}
<span class="sentiment-neutral">Neutral</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<footer>
<div class="brand-name">r/rstat</div>
<div class="brand-subtitle">visit us for more</div>
</footer>
</div>
</body>
</html>