various
This commit is contained in:
@ -76,7 +76,7 @@ class AI(FastAPI):
|
||||
}
|
||||
|
||||
async with ClientSession() as session:
|
||||
async with session.post(data.hook, json=hook_data,
|
||||
async with await session.post(data.hook, json=hook_data,
|
||||
timeout=ClientTimeout(connect=5, sock_read=5), headers={
|
||||
'content-type': 'application/json; charset=utf-8',}) as request:
|
||||
request.raise_for_status()
|
||||
|
@ -45,7 +45,7 @@ class KarmaDB:
|
||||
async def get_karma(self, keyword: str) -> int | dict:
|
||||
"""Get Karma Value for Keyword"""
|
||||
async with sqlite3.connect(self.db_path, timeout=2) as db_conn:
|
||||
async with db_conn.execute("SELECT score FROM karma WHERE keyword LIKE ? LIMIT 1", (keyword,)) as db_cursor:
|
||||
async with await db_conn.execute("SELECT score FROM karma WHERE keyword LIKE ? LIMIT 1", (keyword,)) as db_cursor:
|
||||
try:
|
||||
(score,) = await db_cursor.fetchone()
|
||||
return score
|
||||
@ -59,7 +59,7 @@ class KarmaDB:
|
||||
"""Get Top n=10 Karma Entries"""
|
||||
try:
|
||||
async with sqlite3.connect(self.db_path, timeout=2) as db_conn:
|
||||
async with db_conn.execute("SELECT keyword, score FROM karma ORDER BY score DESC LIMIT ?", (n,)) as db_cursor:
|
||||
async with await db_conn.execute("SELECT keyword, score FROM karma ORDER BY score DESC LIMIT ?", (n,)) as db_cursor:
|
||||
return await db_cursor.fetchall()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
@ -81,17 +81,17 @@ class KarmaDB:
|
||||
logging.debug("Audit message: %s{audit_message}\nKeyword: %s{keyword}")
|
||||
|
||||
async with sqlite3.connect(self.db_path, timeout=2) as db_conn:
|
||||
async with db_conn.execute(audit_query, (keyword, audit_message,)) as db_cursor:
|
||||
async with await db_conn.execute(audit_query, (keyword, audit_message,)) as db_cursor:
|
||||
await db_conn.commit()
|
||||
await db_cursor.close()
|
||||
async with db_conn.execute(query, (now, keyword,)) as db_cursor:
|
||||
async with await db_conn.execute(query, (now, keyword,)) as db_cursor:
|
||||
if db_cursor.rowcount:
|
||||
await db_conn.commit()
|
||||
return True
|
||||
if db_cursor.rowcount < 1: # Keyword does not already exist
|
||||
await db_cursor.close()
|
||||
new_val = 1 if not flag else -1
|
||||
async with db_conn.execute(new_keyword_query, (keyword, new_val, now,)) as db_cursor:
|
||||
async with await db_conn.execute(new_keyword_query, (keyword, new_val, now,)) as db_cursor:
|
||||
if db_cursor.rowcount >= 1:
|
||||
await db_conn.commit()
|
||||
return True
|
||||
|
@ -81,7 +81,7 @@ class CacheUtils:
|
||||
else:
|
||||
query = "SELECT distinct(song) FROM lyrics WHERE artist LIKE ? AND song LIKE ? LIMIT 15"
|
||||
query_params = (f"%{pre_query}%", f"%{s}%",)
|
||||
async with db_conn.execute(query, query_params) as db_cursor:
|
||||
async with await db_conn.execute(query, query_params) as db_cursor:
|
||||
return await db_cursor.fetchall()
|
||||
|
||||
|
||||
|
@ -126,7 +126,6 @@ class Misc(FastAPI):
|
||||
dict
|
||||
"""
|
||||
counts = await self.redis_cache.get_found_counts()
|
||||
logging.info("Got counts: %s - type: %s", counts, type(counts))
|
||||
return counts
|
||||
|
||||
async def homepage_radio_widget(self) -> dict:
|
||||
|
@ -107,7 +107,7 @@ class RandMsg(FastAPI):
|
||||
title_attr = "Donnies DB"
|
||||
|
||||
async with sqlite3.connect(database=randmsg_db_path, timeout=1) as _db:
|
||||
async with _db.execute(db_query) as _cursor:
|
||||
async with await _db.execute(db_query) as _cursor:
|
||||
result = await _cursor.fetchone()
|
||||
(result_id, result_msg) = result
|
||||
result_msg = result_msg.strip()
|
||||
|
@ -82,7 +82,7 @@ class Transcriptions(FastAPI):
|
||||
}
|
||||
await self.glob_state.increment_counter('transcript_list_requests')
|
||||
async with sqlite3.connect(database=db_path, timeout=1) as _db:
|
||||
async with _db.execute(db_query) as _cursor:
|
||||
async with await _db.execute(db_query) as _cursor:
|
||||
result = await _cursor.fetchall()
|
||||
return {
|
||||
"show_title": show_title,
|
||||
@ -120,7 +120,7 @@ class Transcriptions(FastAPI):
|
||||
await self.glob_state.increment_counter('transcript_requests')
|
||||
async with sqlite3.connect(database=db_path, timeout=1) as _db:
|
||||
params = (episode_id,)
|
||||
async with _db.execute(db_query, params) as _cursor:
|
||||
async with await _db.execute(db_query, params) as _cursor:
|
||||
result = await _cursor.fetchall()
|
||||
first_result = result[0]
|
||||
return {
|
||||
|
@ -77,8 +77,8 @@ class XC(FastAPI):
|
||||
}
|
||||
|
||||
bot_api_url = f'http://{BID_ADDR_MAP[bid]}/'
|
||||
async with ClientSession() as session:
|
||||
async with session.post(f"{bot_api_url}{cmd}", json=cmd_data, headers={
|
||||
async with ClientSession() as session:
|
||||
async with await session.post(f"{bot_api_url}{cmd}", json=cmd_data, headers={
|
||||
'Content-Type': 'application/json; charset=utf-8'
|
||||
}, timeout=ClientTimeout(connect=5, sock_read=5)) as request:
|
||||
response = await request.json()
|
||||
|
Reference in New Issue
Block a user