From eaabbb004830b2ad154b1d6b28e8cfa35d7fbe82 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Tue, 10 Dec 2024 21:41:57 +0100 Subject: [PATCH] Add config option to hide YT queries older than a defined cutoff datetime. --- src/ytplom/http.py | 4 +++- src/ytplom/misc.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ytplom/http.py b/src/ytplom/http.py index 9fab277..e726b7c 100644 --- a/src/ytplom/http.py +++ b/src/ytplom/http.py @@ -272,7 +272,9 @@ class _TaskHandler(BaseHTTPRequestHandler): def _send_yt_queries_index_and_search(self) -> None: with DbConn() as conn: quota_count = QuotaLog.current(conn) - queries_data = YoutubeQuery.get_all(conn) + queries_data = [ + q for q in YoutubeQuery.get_all(conn) + if q.retrieved_at > self.server.config.queries_cutoff] queries_data.sort(key=lambda q: q.retrieved_at, reverse=True) self._send_rendered_template(_NAME_TEMPLATE_QUERIES, {'queries': queries_data, diff --git a/src/ytplom/misc.py b/src/ytplom/misc.py index f7d2909..2b73b99 100644 --- a/src/ytplom/misc.py +++ b/src/ytplom/misc.py @@ -27,7 +27,8 @@ DEFAULTS = { 'host': '127.0.0.1', # NB: to be found remotely, use '0.0.0.0'! 'port': 8090, 'port_remote': 8090, - 'background_color': '#ffffff' + 'background_color': '#ffffff', + 'queries_cutoff': '' } # type definitions for mypy @@ -91,6 +92,7 @@ class Config: port_remote: int api_key: str background_color: str + queries_cutoff: str def __init__(self): def set_attrs_from_dict(d): -- 2.30.2