This commit is contained in:
2025-02-21 14:11:39 -05:00
parent 7c66ce7b35
commit 5d4335f92d
2 changed files with 8 additions and 7 deletions

View File

@ -93,15 +93,14 @@ class RedisCache:
src = src.strip().lower()
await self.redis_client.incr(f"returned:{src}")
except Exception as e:
file = __file__.rsplit("/", maxsplit=1)[-1]
file: str = __file__.rsplit("/", maxsplit=1)[-1]
await self.notifier.send(f"ERROR @ {file}", str(e))
traceback.print_exc()
async def get_found_counts(self) -> Optional[dict]:
"""
Get found counts for all sources (and failed count)
Args:
None
Returns:
dict: In the form {'source': count, 'source2': count, ...}
"""
@ -110,12 +109,10 @@ class RedisCache:
counts: dict[str, int] = {}
for src in sources:
src_found_count = await self.redis_client.get(f"returned:{src}")
if not isinstance(src_found_count, int):
return None
counts[src] = int(src_found_count) # Redis returns bytes
return counts
except Exception as e:
file = __file__.rsplit("/", maxsplit=1)[-1]
file: str = __file__.rsplit("/", maxsplit=1)[-1]
await self.notifier.send(f"ERROR @ {file}", str(e))
traceback.print_exc()
return None
@ -184,6 +181,7 @@ class RedisCache:
traceback.print_exc()
# await self.notifier.send(f"ERROR @ {__file__.rsplit("/", maxsplit=1)[-1]}", f"{str(e)}\nSearch was: {artist} - {song}; fuzzy: {fuzzy_artist} - {fuzzy_song}")
return None
async def redis_store(self, sqlite_id: int,
lyr_result: LyricsResult) -> None:
"""
@ -222,7 +220,7 @@ class RedisCache:
await self.notifier.send("INFO",
f"Stored {lyr_result.artist} - {lyr_result.song} (related SQLite Row ID: {sqlite_id}) to redis: {newkey}")
except Exception as e:
file = __file__.rsplit("/", maxsplit=1)[-1]
file: str = __file__.rsplit("/", maxsplit=1)[-1]
await self.notifier.send(f"ERROR @ {file}",
f"Failed to store {lyr_result.artist} - {lyr_result.song}\
(SQLite id: {sqlite_id}) to Redis:\n{str(e)}")