Spaces:
Running
Running
Download news/windows.py from Success-dev/venthrive-api: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/Success-dev/venthrive-api/resolve/main/news/windows.py
- Command line
-
hf download hf://spaces/Success-dev/venthrive-api/news/windows.py
-
curl -L -o windows.py https://huggingface.co/spaces/Success-dev/venthrive-api/resolve/main/news/windows.py
1.07 kB
| """ | |
| Default relevance windows per category (ADR-0015). These are starting points, | |
| not final — day counts picked before any real classified history existed, to | |
| be revisited once there's enough data to see how fast each category actually | |
| goes stale. | |
| An opportunity with an explicit deadline in the source text uses that deadline | |
| instead of its category's default window — see classify.py. | |
| """ | |
| from datetime import datetime, timedelta, timezone, date | |
| CATEGORY_WINDOW_DAYS = { | |
| "weather": 7, | |
| "infrastructure": 14, | |
| "security": 14, | |
| "policy": 90, | |
| "funding": 30, | |
| "other": 21, | |
| } | |
| DEFAULT_WINDOW_DAYS = 21 | |
| def compute_expiry(category: str | None, scraped_at: datetime, deadline: date | None) -> datetime: | |
| """The point at which an item stops being shown to users.""" | |
| if deadline is not None: | |
| return datetime.combine(deadline, datetime.min.time(), tzinfo=timezone.utc) | |
| days = CATEGORY_WINDOW_DAYS.get(category or "", DEFAULT_WINDOW_DAYS) | |
| return scraped_at + timedelta(days=days) | |