From: Christian Heller Date: Tue, 10 Dec 2024 20:41:57 +0000 (+0100) Subject: Add config option to hide YT queries older than a defined cutoff datetime. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bdb.prefix%7D%7D/%7B%7Byoutube_prefix%7D%7D%7B%7Bresult.id%7D%7D?a=commitdiff_plain;h=eaabbb004830b2ad154b1d6b28e8cfa35d7fbe82;p=ytplom Add config option to hide YT queries older than a defined cutoff datetime. --- 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):