Add functionality to only update top tickers.
This commit is contained in:
@@ -348,4 +348,32 @@ def get_ticker_by_symbol(symbol):
|
||||
cursor.execute("SELECT id, symbol FROM tickers WHERE LOWER(symbol) = LOWER(?)", (symbol,))
|
||||
result = cursor.fetchone()
|
||||
conn.close()
|
||||
return result
|
||||
return result
|
||||
|
||||
def get_top_daily_ticker_symbols():
|
||||
"""Gets a simple list of the Top 10 ticker symbols from the last 24 hours."""
|
||||
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 FROM mentions m JOIN tickers t ON m.ticker_id = t.id
|
||||
WHERE m.mention_timestamp >= ?
|
||||
GROUP BY t.symbol ORDER BY COUNT(m.id) DESC LIMIT 10;
|
||||
"""
|
||||
results = conn.execute(query, (one_day_ago_timestamp,)).fetchall()
|
||||
conn.close()
|
||||
return [row['symbol'] for row in results] # Return a simple list of strings
|
||||
|
||||
def get_top_weekly_ticker_symbols():
|
||||
"""Gets a simple list of the Top 10 ticker symbols from the last 7 days."""
|
||||
conn = get_db_connection()
|
||||
seven_days_ago = datetime.now(timezone.utc) - timedelta(days=7)
|
||||
seven_days_ago_timestamp = int(seven_days_ago.timestamp())
|
||||
query = """
|
||||
SELECT t.symbol FROM mentions m JOIN tickers t ON m.ticker_id = t.id
|
||||
WHERE m.mention_timestamp >= ?
|
||||
GROUP BY t.symbol ORDER BY COUNT(m.id) DESC LIMIT 10;
|
||||
"""
|
||||
results = conn.execute(query, (seven_days_ago_timestamp,)).fetchall()
|
||||
conn.close()
|
||||
return [row['symbol'] for row in results] # Return a simple list of strings
|
Reference in New Issue
Block a user