Change dashboards to show daily only.
This commit is contained in:
@@ -204,31 +204,47 @@ def add_or_update_post_analysis(conn, post_data):
|
|||||||
)
|
)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
def get_overall_summary(limit=50):
|
def get_overall_summary(limit=10):
|
||||||
|
"""
|
||||||
|
Gets the top tickers across all subreddits from the LAST 24 HOURS.
|
||||||
|
"""
|
||||||
conn = get_db_connection()
|
conn = get_db_connection()
|
||||||
|
one_day_ago = datetime.now(timezone.utc) - timedelta(days=1)
|
||||||
|
one_day_ago_timestamp = int(one_day_ago.timestamp())
|
||||||
|
|
||||||
query = """
|
query = """
|
||||||
SELECT t.symbol, t.market_cap, t.closing_price, COUNT(m.id) as mention_count,
|
SELECT t.symbol, t.market_cap, t.closing_price, COUNT(m.id) as mention_count,
|
||||||
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 bullish_mentions,
|
||||||
SUM(CASE WHEN m.mention_sentiment < -0.1 THEN 1 ELSE 0 END) as bearish_mentions,
|
SUM(CASE WHEN m.mention_sentiment < -0.1 THEN 1 ELSE 0 END) as bearish_mentions,
|
||||||
SUM(CASE WHEN m.mention_sentiment BETWEEN -0.1 AND 0.1 THEN 1 ELSE 0 END) as neutral_mentions
|
SUM(CASE WHEN m.mention_sentiment BETWEEN -0.1 AND 0.1 THEN 1 ELSE 0 END) as neutral_mentions
|
||||||
FROM mentions m JOIN tickers t ON m.ticker_id = t.id
|
FROM mentions m JOIN tickers t ON m.ticker_id = t.id
|
||||||
GROUP BY t.symbol, t.market_cap, t.closing_price ORDER BY mention_count DESC LIMIT ?;
|
WHERE m.mention_timestamp >= ? -- <-- ADDED TIME FILTER
|
||||||
|
GROUP BY t.symbol, t.market_cap, t.closing_price
|
||||||
|
ORDER BY mention_count DESC LIMIT ?;
|
||||||
"""
|
"""
|
||||||
results = conn.execute(query, (limit,)).fetchall()
|
results = conn.execute(query, (one_day_ago_timestamp, limit)).fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def get_subreddit_summary(subreddit_name, limit=50):
|
def get_subreddit_summary(subreddit_name, limit=10):
|
||||||
|
"""
|
||||||
|
Gets the top tickers for a specific subreddit from the LAST 24 HOURS.
|
||||||
|
"""
|
||||||
conn = get_db_connection()
|
conn = get_db_connection()
|
||||||
|
one_day_ago = datetime.now(timezone.utc) - timedelta(days=1)
|
||||||
|
one_day_ago_timestamp = int(one_day_ago.timestamp())
|
||||||
|
|
||||||
query = """
|
query = """
|
||||||
SELECT t.symbol, t.market_cap, t.closing_price, COUNT(m.id) as mention_count,
|
SELECT t.symbol, t.market_cap, t.closing_price, COUNT(m.id) as mention_count,
|
||||||
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 bullish_mentions,
|
||||||
SUM(CASE WHEN m.mention_sentiment < -0.1 THEN 1 ELSE 0 END) as bearish_mentions,
|
SUM(CASE WHEN m.mention_sentiment < -0.1 THEN 1 ELSE 0 END) as bearish_mentions,
|
||||||
SUM(CASE WHEN m.mention_sentiment BETWEEN -0.1 AND 0.1 THEN 1 ELSE 0 END) as neutral_mentions
|
SUM(CASE WHEN m.mention_sentiment BETWEEN -0.1 AND 0.1 THEN 1 ELSE 0 END) as neutral_mentions
|
||||||
FROM mentions m JOIN tickers t ON m.ticker_id = t.id JOIN subreddits s ON m.subreddit_id = s.id
|
FROM mentions m JOIN tickers t ON m.ticker_id = t.id JOIN subreddits s ON m.subreddit_id = s.id
|
||||||
WHERE LOWER(s.name) = LOWER(?) GROUP BY t.symbol, t.market_cap, t.closing_price ORDER BY mention_count DESC LIMIT ?;
|
WHERE LOWER(s.name) = LOWER(?) AND m.mention_timestamp >= ? -- <-- ADDED TIME FILTER
|
||||||
|
GROUP BY t.symbol, t.market_cap, t.closing_price
|
||||||
|
ORDER BY mention_count DESC LIMIT ?;
|
||||||
"""
|
"""
|
||||||
results = conn.execute(query, (subreddit_name, limit)).fetchall()
|
results = conn.execute(query, (subreddit_name, one_day_ago_timestamp, limit)).fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@@ -274,8 +290,12 @@ def get_weekly_summary_for_subreddit(subreddit_name, for_date):
|
|||||||
return results, start_of_week, end_of_week
|
return results, start_of_week, end_of_week
|
||||||
|
|
||||||
def get_overall_image_view_summary():
|
def get_overall_image_view_summary():
|
||||||
""" Gets a summary of top tickers across ALL subreddits for the image view. """
|
"""
|
||||||
|
Gets a summary of top tickers across ALL subreddits for the DAILY image view (last 24 hours).
|
||||||
|
"""
|
||||||
conn = get_db_connection()
|
conn = get_db_connection()
|
||||||
|
one_day_ago = datetime.now(timezone.utc) - timedelta(days=1)
|
||||||
|
one_day_ago_timestamp = int(one_day_ago.timestamp())
|
||||||
query = """
|
query = """
|
||||||
SELECT
|
SELECT
|
||||||
t.symbol, t.market_cap, t.closing_price,
|
t.symbol, t.market_cap, t.closing_price,
|
||||||
@@ -283,10 +303,11 @@ def get_overall_image_view_summary():
|
|||||||
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 bullish_mentions,
|
||||||
COUNT(CASE WHEN m.mention_sentiment < -0.1 THEN 1 END) as bearish_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
|
FROM mentions m JOIN tickers t ON m.ticker_id = t.id
|
||||||
|
WHERE m.mention_timestamp >= ? -- <-- ADDED TIME FILTER
|
||||||
GROUP BY t.symbol, t.market_cap, t.closing_price
|
GROUP BY t.symbol, t.market_cap, t.closing_price
|
||||||
ORDER BY total_mentions DESC LIMIT 10;
|
ORDER BY total_mentions DESC LIMIT 10;
|
||||||
"""
|
"""
|
||||||
results = conn.execute(query).fetchall()
|
results = conn.execute(query, (one_day_ago_timestamp,)).fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>
|
<h1>
|
||||||
Top 10 Tickers (All Subreddits)
|
Top 10 Tickers Today (All Subreddits)
|
||||||
<!-- ADD THIS LINK -->
|
<!-- ADD THIS LINK -->
|
||||||
<a href="/image/overall" target="_blank" style="font-size: 0.8rem; margin-left: 1rem; font-weight: normal;">image</a>
|
<a href="/image/overall" target="_blank" style="font-size: 0.8rem; margin-left: 1rem; font-weight: normal;">image</a>
|
||||||
</h1>
|
</h1>
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>
|
<h1>
|
||||||
Top 10 Tickers in r/{{ subreddit_name }}
|
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/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>
|
<a href="/image/weekly/{{ subreddit_name }}" target="_blank" style="font-size: 0.8rem; margin-left: 1rem; font-weight: normal;">weekly image</a>
|
||||||
</h1>
|
</h1>
|
||||||
|
Reference in New Issue
Block a user