misc
This commit is contained in:
@ -10,7 +10,7 @@ from redis.commands.search.query import Query
|
||||
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
|
||||
from redis.commands.search.field import TextField, TagField
|
||||
from redis.commands.json.path import Path
|
||||
from lyric_search_new.sources import private, cache as LyricsCache
|
||||
from lyric_search_new.sources import private, cache as LyricsCache, redis_cache
|
||||
|
||||
class Misc(FastAPI):
|
||||
"""Misc Endpoints"""
|
||||
@ -20,10 +20,12 @@ class Misc(FastAPI):
|
||||
self.constants = constants
|
||||
self.glob_state = glob_state
|
||||
self.lyr_cache = LyricsCache.Cache()
|
||||
self.redis_cache = redis_cache.RedisCache()
|
||||
self.redis_client = redis.Redis(password=private.REDIS_PW)
|
||||
self.endpoints = {
|
||||
"widget/redis": self.homepage_redis_widget,
|
||||
"widget/sqlite": self.homepage_sqlite_widget,
|
||||
"widget/lyrics": self.homepage_lyrics_widget,
|
||||
}
|
||||
|
||||
for endpoint, handler in self.endpoints.items():
|
||||
@ -32,7 +34,7 @@ class Misc(FastAPI):
|
||||
async def homepage_redis_widget(self) -> dict:
|
||||
"""
|
||||
/widget/redis/
|
||||
Homepage Widget Handler
|
||||
Homepage Redis Widget Handler
|
||||
Args:
|
||||
None
|
||||
Returns:
|
||||
@ -61,7 +63,7 @@ class Misc(FastAPI):
|
||||
async def homepage_sqlite_widget(self) -> dict:
|
||||
"""
|
||||
/widget/sqlite/
|
||||
Homepage Widget Handler
|
||||
Homepage SQLite Widget Handler
|
||||
Args:
|
||||
None
|
||||
Returns:
|
||||
@ -74,4 +76,17 @@ class Misc(FastAPI):
|
||||
'storedRows': row_count,
|
||||
'distinctArtists': distinct_artists,
|
||||
'lyricsLength': lyrics_length,
|
||||
}
|
||||
}
|
||||
|
||||
async def homepage_lyrics_widget(self) -> dict:
|
||||
"""
|
||||
/widget/lyrics/
|
||||
Homepage Lyrics Widget Handler
|
||||
Args:
|
||||
None
|
||||
Returns:
|
||||
dict
|
||||
"""
|
||||
counts = await self.redis_cache.get_found_counts()
|
||||
logging.info("Got counts: %s - type: %s", counts, type(counts))
|
||||
return counts
|
Reference in New Issue
Block a user