Added overall image view and more blacklisted words.

This commit is contained in:
2025-07-22 10:31:16 +02:00
parent ef91b735b7
commit fb1b2c1b20
6 changed files with 269 additions and 96 deletions

View File

@@ -369,4 +369,27 @@ def get_weekly_summary_for_subreddit(subreddit_name):
"""
results = conn.execute(query, (subreddit_name, seven_days_ago_timestamp)).fetchall()
conn.close()
return results
def get_overall_image_view_summary():
"""
Gets a summary of top tickers across ALL subreddits for the image view.
"""
conn = get_db_connection()
query = """
SELECT
t.symbol,
COUNT(CASE WHEN m.mention_type = 'post' THEN 1 END) as post_mentions,
COUNT(CASE WHEN m.mention_type = 'comment' THEN 1 END) as comment_mentions,
COUNT(CASE WHEN m.mention_sentiment > 0.1 THEN 1 END) as bullish_mentions,
COUNT(CASE WHEN m.mention_sentiment < -0.1 THEN 1 END) as bearish_mentions
FROM mentions m
JOIN tickers t ON m.ticker_id = t.id
-- No JOIN or WHERE for subreddit, as we want all of them
GROUP BY t.symbol
ORDER BY (post_mentions + comment_mentions) DESC
LIMIT 10;
"""
results = conn.execute(query).fetchall()
conn.close()
return results