Browse Source

Do not ask for snapshots that are in the future

jherve 1 năm trước cách đây
mục cha
commit
cafdb28026
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 5 1
      src/de_quoi_parle_le_monde/snapshots.py

+ 5 - 1
src/de_quoi_parle_le_monde/snapshots.py

@@ -30,10 +30,14 @@ class SnapshotJob:
 
     @staticmethod
     def last_n_days_at_hours(n: int, hours: list[int]) -> list[datetime]:
+        now = datetime.now()
+
         return [
-            datetime.combine(date.today() - timedelta(days=i), time(hour=h))
+            dt
             for i in range(0, n)
             for h in hours
+            if (dt := datetime.combine(date.today() - timedelta(days=i), time(hour=h)))
+            < now
         ]