From ee8407a7e7650365fb66d9565150857972bafd9d Mon Sep 17 00:00:00 2001 From: codey Date: Wed, 12 Feb 2025 09:45:55 -0500 Subject: [PATCH] minor cleanup --- endpoints/rand_msg.py | 27 ++++++++++++++------------- endpoints/transcriptions.py | 1 - 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/endpoints/rand_msg.py b/endpoints/rand_msg.py index 0998ece..3718b41 100644 --- a/endpoints/rand_msg.py +++ b/endpoints/rand_msg.py @@ -2,6 +2,7 @@ import os import random +from typing import LiteralString import aiosqlite as sqlite3 from fastapi import FastAPI from .constructors import RandMsgRequest @@ -57,38 +58,38 @@ class RandMsg(FastAPI): ORDER BY RANDOM() LIMIT 1" # For Trump Tweet DB title_attr = "Trump Tweet DB" case 3: - randmsg_db_path = os.path.join("/", + randmsg_db_path: str|LiteralString = os.path.join("/", "usr", "local", "share", "sqlite_dbs", "philo.db") # For Philo DB - db_query = "SELECT id, (content || '
- ' || speaker) FROM quotes \ + db_query: str = "SELECT id, (content || '
- ' || speaker) FROM quotes \ ORDER BY RANDOM() LIMIT 1" # For Philo DB - title_attr = "Philosophical Quotes DB" + title_attr: str = "Philosophical Quotes DB" case 4: - randmsg_db_path = os.path.join("/", + randmsg_db_path: str|LiteralString = os.path.join("/", "usr", "local", "share", "sqlite_dbs", "hate.db") # For Hate DB - db_query = """SELECT id, ("" || comment) FROM hate_speech \ + db_query: str = """SELECT id, ("" || comment) FROM hate_speech \ WHERE length(comment) <= 180 ORDER BY RANDOM() LIMIT 1""" - title_attr = "Hate Speech DB" + title_attr: str = "Hate Speech DB" case 5: - randmsg_db_path = os.path.join("/", + randmsg_db_path: str|LiteralString = os.path.join("/", "usr", "local", "share", "sqlite_dbs", "rjokes.db") # r/jokes DB - db_query = """SELECT id, (title || "
" || body) FROM jokes \ + db_query: str = """SELECT id, (title || "
" || body) FROM jokes \ WHERE score >= 10000 ORDER BY RANDOM() LIMIT 1""" - title_attr = "r/jokes DB" + title_attr: str = "r/jokes DB" case 6: - randmsg_db_path = os.path.join("/", + randmsg_db_path: str|LiteralString = os.path.join("/", "usr", "local", "share", "sqlite_dbs", "donnies.db") # Donnies DB random.seed() - twilight_or_mice = random.choice(["twilight", "mice"]) - db_query = f"SELECT id, text FROM {twilight_or_mice} ORDER BY RANDOM() LIMIT 1" - title_attr = "Donnies DB" + twilight_or_mice: str = random.choice(["twilight", "mice"]) + db_query: str = f"SELECT id, text FROM {twilight_or_mice} ORDER BY RANDOM() LIMIT 1" + title_attr: str = "Donnies DB" async with sqlite3.connect(database=randmsg_db_path, timeout=1) as _db: async with await _db.execute(db_query) as _cursor: diff --git a/endpoints/transcriptions.py b/endpoints/transcriptions.py index ad93da3..edcf615 100644 --- a/endpoints/transcriptions.py +++ b/endpoints/transcriptions.py @@ -26,7 +26,6 @@ class Transcriptions(FastAPI): async def get_episodes_handler(self, data: ValidShowEpisodeListRequest) -> dict: """Get list of episodes by show id""" - show_id: int = data.s db_path: Optional[str|LiteralString] = None db_query: Optional[str] = None