Private
Public Access
Make the feed-poll interval site-wide instead of per-feed
Replaces Feed.fetch_interval_minutes with a single admin-editable SiteSettings.fetch_interval_minutes (apps.core), following the same singleton-row pattern as accounts.SetupLock. Per-feed error backoff is unchanged — only the configured baseline interval is now shared across every feed, loaded once per poll_due_feeds run rather than queried per feed. EVECTION_MIN_FETCH_INTERVAL_MINUTES keeps working as the floor underneath it. SiteSettings is registered in Django admin as a singleton: "Add" is only offered when no row exists yet, and delete is always refused. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a1ea2e5662
commit
dc8b9ff83b
11 files changed
+203
-20
No files matched your search
@@ -124,14 +124,17 @@ def _entry_content_html(entry) -> str:
|
||||
return getattr(entry, "summary", "") or ""
|
||||
|
||||
|
||||
def effective_interval_minutes(feed: Feed) -> int:
|
||||
"""The actual polling interval to use, applying exponential backoff on
|
||||
top of the admin-configured ``fetch_interval_minutes`` for feeds that
|
||||
are currently erroring. ``fetch_interval_minutes`` itself is never
|
||||
mutated by the fetcher — it's the admin's chosen baseline.
|
||||
def effective_interval_minutes(feed: Feed, configured_interval_minutes: int) -> int:
|
||||
"""The actual polling interval to use for `feed`, applying exponential
|
||||
backoff on top of the site-wide `configured_interval_minutes` (see
|
||||
apps.core.models.SiteSettings) for a feed that's currently erroring.
|
||||
Takes the configured value as a parameter rather than querying
|
||||
SiteSettings itself, since this runs once per feed (apps.feeds.tasks
|
||||
calls it from a list comprehension over every active feed) and the
|
||||
site-wide value doesn't vary by feed.
|
||||
"""
|
||||
floor = getattr(settings, "EVECTION_MIN_FETCH_INTERVAL_MINUTES", 15)
|
||||
base = max(feed.fetch_interval_minutes, floor)
|
||||
base = max(configured_interval_minutes, floor)
|
||||
if feed.fetch_error_count <= 0:
|
||||
return base
|
||||
backoff = base * (2**feed.fetch_error_count)
|
||||
|
||||
Reference in new issue
Block a user