Refactored and redesigned dashboards.
This commit is contained in:
@@ -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()
|
||||
|
Reference in New Issue
Block a user