AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
Python ai-promptsai-skillblueskyclaudeclaude-codeclawhubdeep-researchhackernewsinstagramopenclawpolymarketrecencyredditresearchsocial-mediatiktoktrendstwitterweb-searchyoutube
fix(reddit): round fetch bucket up for rolling Reddit windows
Trevin Chowd9d0019af89f
diff --git a/skills/last30days/scripts/lib/reddit.py b/skills/last30days/scripts/lib/reddit.pyindex 8f5bf167..741bac32 100644--- a/skills/last30days/scripts/lib/reddit.py+++ b/skills/last30days/scripts/lib/reddit.py@@ -459,9 +459,12 @@ _TIMEFRAME_ORDER = {"hour": 0, "day": 1, "week": 2, "month": 3, "year": 4, "all"def _window_to_time_filter(from_date: str, to_date: str) -> str:"""Map a requested YYYY-MM-DD window onto Reddit's coarse `t` param.- Reddit filters server-side only at hour/day/week/month granularity. Pick the- smallest bucket that covers the window. Falls back to 'month' (previous- behaviour) if the dates don't parse.+ Reddit's ``t=day|week|month`` buckets are rolling windows ending "now", not+ calendar spans. A one-day request often covers yesterday→today, so ``t=day``+ (last 24h) under-fetches yesterday morning and the later date filter cannot+ recover those posts. Round up one bucket so the fetch covers the calendar+ window; Phase 5 still trims to ``from_date``/``to_date``. Falls back to+ ``month`` (previous behaviour) if the dates don't parse."""try:span = (time.mktime(time.strptime(to_date, "%Y-%m-%d"))@@ -469,11 +472,11 @@ def _window_to_time_filter(from_date: str, to_date: str) -> str:except (ValueError, TypeError):return "month"if span <= 1:- return "day"- if span <= 7:return "week"- if span <= 31:+ if span <= 7:return "month"+ if span <= 31:+ return "year"if span <= 366:return "year"return "all"diff --git a/tests/test_reddit.py b/tests/test_reddit.pyindex e14476ce..1028027c 100644--- a/tests/test_reddit.py+++ b/tests/test_reddit.py@@ -262,3 +262,12 @@ class TestEnrichmentBudget(unittest.TestCase):if __name__ == "__main__":unittest.main()+++def test_window_to_time_filter_rounds_up_for_rolling_buckets():+ """Calendar windows need the next Reddit rolling bucket (Greptile on #860)."""+ from lib import reddit++ assert reddit._window_to_time_filter("2026-07-23", "2026-07-24") == "week"+ assert reddit._window_to_time_filter("2026-07-17", "2026-07-24") == "month"+ assert reddit._window_to_time_filter("2026-06-24", "2026-07-24") == "year"