Change logic to store all subreddits as lowercase.
This commit is contained in:
@@ -310,7 +310,7 @@ def get_deep_dive_details(ticker_symbol):
|
|||||||
JOIN mentions m ON p.post_id = m.post_id
|
JOIN mentions m ON p.post_id = m.post_id
|
||||||
JOIN tickers t ON m.ticker_id = t.id
|
JOIN tickers t ON m.ticker_id = t.id
|
||||||
JOIN subreddits s ON p.subreddit_id = s.id
|
JOIN subreddits s ON p.subreddit_id = s.id
|
||||||
WHERE t.symbol = ?
|
WHERE LOWER(t.symbol) = LOWER(?)
|
||||||
ORDER BY p.post_timestamp DESC;
|
ORDER BY p.post_timestamp DESC;
|
||||||
"""
|
"""
|
||||||
results = conn.execute(query, (ticker_symbol,)).fetchall()
|
results = conn.execute(query, (ticker_symbol,)).fetchall()
|
||||||
@@ -346,7 +346,7 @@ def get_subreddit_summary(subreddit_name, limit=50):
|
|||||||
FROM mentions m
|
FROM mentions m
|
||||||
JOIN tickers t ON m.ticker_id = t.id
|
JOIN tickers t ON m.ticker_id = t.id
|
||||||
JOIN subreddits s ON m.subreddit_id = s.id
|
JOIN subreddits s ON m.subreddit_id = s.id
|
||||||
WHERE s.name = ?
|
WHERE LOWER(s.name) = LOWER(?)
|
||||||
GROUP BY t.symbol, t.market_cap, t.closing_price
|
GROUP BY t.symbol, t.market_cap, t.closing_price
|
||||||
ORDER BY mention_count DESC LIMIT ?;
|
ORDER BY mention_count DESC LIMIT ?;
|
||||||
"""
|
"""
|
||||||
@@ -366,7 +366,7 @@ def get_image_view_summary(subreddit_name):
|
|||||||
FROM mentions m
|
FROM mentions m
|
||||||
JOIN tickers t ON m.ticker_id = t.id
|
JOIN tickers t ON m.ticker_id = t.id
|
||||||
JOIN subreddits s ON m.subreddit_id = s.id
|
JOIN subreddits s ON m.subreddit_id = s.id
|
||||||
WHERE s.name = ?
|
WHERE LOWER(s.name) = LOWER(?)
|
||||||
GROUP BY t.symbol
|
GROUP BY t.symbol
|
||||||
ORDER BY (post_mentions + comment_mentions) DESC
|
ORDER BY (post_mentions + comment_mentions) DESC
|
||||||
LIMIT 10;
|
LIMIT 10;
|
||||||
@@ -389,7 +389,7 @@ def get_weekly_summary_for_subreddit(subreddit_name):
|
|||||||
FROM mentions m
|
FROM mentions m
|
||||||
JOIN tickers t ON m.ticker_id = t.id
|
JOIN tickers t ON m.ticker_id = t.id
|
||||||
JOIN subreddits s ON m.subreddit_id = s.id
|
JOIN subreddits s ON m.subreddit_id = s.id
|
||||||
WHERE s.name = ? AND m.mention_timestamp >= ?
|
WHERE LOWER(s.name) = LOWER(?) AND m.mention_timestamp >= ?
|
||||||
GROUP BY t.symbol
|
GROUP BY t.symbol
|
||||||
ORDER BY (post_mentions + comment_mentions) DESC
|
ORDER BY (post_mentions + comment_mentions) DESC
|
||||||
LIMIT 10;
|
LIMIT 10;
|
||||||
|
@@ -55,9 +55,12 @@ def scan_subreddits(reddit, subreddits_list, post_limit=100, comment_limit=100,
|
|||||||
print(f"\nScanning {len(subreddits_list)} subreddit(s) for NEW posts in the last {days_to_scan} day(s)...")
|
print(f"\nScanning {len(subreddits_list)} subreddit(s) for NEW posts in the last {days_to_scan} day(s)...")
|
||||||
for subreddit_name in subreddits_list:
|
for subreddit_name in subreddits_list:
|
||||||
try:
|
try:
|
||||||
subreddit_id = database.get_or_create_entity(conn, 'subreddits', 'name', subreddit_name)
|
# Always use the lowercase version of the name for consistency.
|
||||||
subreddit = reddit.subreddit(subreddit_name)
|
normalized_sub_name = subreddit_name.lower()
|
||||||
print(f"Scanning r/{subreddit_name}...")
|
|
||||||
|
subreddit_id = database.get_or_create_entity(conn, 'subreddits', 'name', normalized_sub_name)
|
||||||
|
subreddit = reddit.subreddit(normalized_sub_name)
|
||||||
|
print(f"Scanning r/{normalized_sub_name}...")
|
||||||
|
|
||||||
for submission in subreddit.new(limit=post_limit):
|
for submission in subreddit.new(limit=post_limit):
|
||||||
if (current_time - submission.created_utc) > post_age_limit:
|
if (current_time - submission.created_utc) > post_age_limit:
|
||||||
|
Reference in New Issue
Block a user