From f68abca2b1be5e3002673de92e56186594b1f5b0 Mon Sep 17 00:00:00 2001 From: codey Date: Sun, 16 Feb 2025 14:20:39 -0500 Subject: [PATCH] p3 & dedupe typeahead results --- endpoints/radio_util.py | 2 +- endpoints/rand_msg.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/endpoints/radio_util.py b/endpoints/radio_util.py index 60c4271..1d9812d 100644 --- a/endpoints/radio_util.py +++ b/endpoints/radio_util.py @@ -71,7 +71,7 @@ class RadioUtil: async with sqlite3.connect(self.active_playlist_path, timeout=1) as _db: _db.row_factory = sqlite3.Row - db_query: str = 'SELECT (artist || " - " || song) as artistsong FROM tracks WHERE\ + db_query: str = 'SELECT DISTINCT(artist || " - " || song) as artistsong FROM tracks WHERE\ artistsong LIKE ? LIMIT 30' db_params: tuple[str] = (f"%{query}%",) async with _db.execute(db_query, db_params) as _cursor: diff --git a/endpoints/rand_msg.py b/endpoints/rand_msg.py index 854b704..e739e51 100644 --- a/endpoints/rand_msg.py +++ b/endpoints/rand_msg.py @@ -30,7 +30,8 @@ class RandMsg(FastAPI): short: Optional[bool] = False if isinstance(data, RandMsgRequest): short = data.short - db_rand_selected: int = 9 + if short: + db_rand_selected: int = 9 db_rand_selected = random.choice([0, 1, 3]) title_attr: str = "Unknown"