diff --git a/endpoints/misc.py b/endpoints/misc.py index 712a9f7..64288c6 100644 --- a/endpoints/misc.py +++ b/endpoints/misc.py @@ -32,7 +32,8 @@ class Misc(FastAPI): } for endpoint, handler in self.endpoints.items(): - app.add_api_route(f"/{endpoint}/", handler, methods=["GET"]) + app.add_api_route(f"/{endpoint}/", handler, methods=["GET"], + include_in_schema=False) async def get_radio_np(self) -> dict: """ diff --git a/lyric_search_new/sources/cache.py b/lyric_search_new/sources/cache.py index dd56596..39b3b06 100644 --- a/lyric_search_new/sources/cache.py +++ b/lyric_search_new/sources/cache.py @@ -12,7 +12,7 @@ sys.path.insert(1,'.') from typing import Optional, Any import aiosqlite as sqlite3 from . import redis_cache -from lyric_search_new import utils +from lyric_search_new import utils, notifier from lyric_search_new.constructors import LyricsResult @@ -27,6 +27,7 @@ class Cache: "lib", "singerdbs", "cached_lyrics.db") self.redis_cache = redis_cache.RedisCache() + self.notifier = notifier.DiscordNotifier() self.cache_pre_query: str = "pragma journal_mode = WAL; pragma synchronous = normal;\ pragma temp_store = memory; pragma mmap_size = 30000000000;" @@ -108,10 +109,16 @@ class Cache: Returns: None """ - sqlite_insert_id = await self.sqlite_store(lyr_result) - if sqlite_insert_id: - await self.redis_cache.redis_store(sqlite_insert_id, lyr_result) - + try: + sqlite_insert_id = await self.sqlite_store(lyr_result) + if sqlite_insert_id: + await self.redis_cache.redis_store(sqlite_insert_id, lyr_result) + except Exception as e: + traceback.print_exc() + logging.error("ERROR @ %s: %s", + __file__.rsplit("/", maxsplit=1)[-1], f"cache::store >> {str(e)}") + await self.notifier.send(f"ERROR @ {__file__.rsplit("/", maxsplit=1)[-1]}", + f"cache::store >> {str(e)}") async def sqlite_rowcount(self, where: Optional[str] = None, params: Optional[tuple] = None) -> int: """