瀏覽代碼

Change to_ parameter in request to not always hit the cache in some cases

jherve 1 年之前
父節點
當前提交
1b139f81e6
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      src/de_quoi_parle_le_monde/internet_archive.py

+ 6 - 1
src/de_quoi_parle_le_monde/internet_archive.py

@@ -109,7 +109,12 @@ class InternetArchiveClient:
         req = CdxRequest(
             url=url,
             from_=dt - timedelta(hours=6.0),
-            to_=dt + timedelta(hours=6.0),
+            # It does not make sense to ask for snapshots in the future.
+            # In the case where the requested `dt` is in the future, this
+            # also allows to always send a new actual request and not
+            # hit the cache, but this is obviously an implementation detail
+            # of the HTTP layer that this client should not be aware of..
+            to_=min(dt + timedelta(hours=6.0), datetime.now()),
             filter="statuscode:200",
         )