minor cleanup
This commit is contained in:
parent
09dd9db970
commit
ee8407a7e7
@ -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 || '<br> - ' || speaker) FROM quotes \
|
||||
db_query: str = "SELECT id, (content || '<br> - ' || 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, ("<font color='#FF0000'>" || comment) FROM hate_speech \
|
||||
db_query: str = """SELECT id, ("<font color='#FF0000'>" || 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 || "<br>" || body) FROM jokes \
|
||||
db_query: str = """SELECT id, (title || "<br>" || 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:
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user