home · contact · privacy
Add config option to hide YT queries older than a defined cutoff datetime.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 10 Dec 2024 20:41:57 +0000 (21:41 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 10 Dec 2024 20:41:57 +0000 (21:41 +0100)
src/ytplom/http.py
src/ytplom/misc.py

index 9fab2777903c0cb94e7e7393e95520724de2c561..e726b7c2af1c4d8c1d7efa362e5dbd38335928d7 100644 (file)
@@ -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,
index f7d29094a0824e42ba0a7b7cda04e981602233ec..2b73b9911e91418f4ec9b2ed736e328fdd29ad56 100644 (file)
@@ -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):