Private
Public Access
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>
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
from django.db import models
|
|
|
|
|
|
class SiteSettings(models.Model):
|
|
"""Singleton row (pk=1, same pattern as accounts.SetupLock) holding
|
|
instance-wide configuration an operator reasonably wants to change
|
|
without touching the server or .env — editable via Django admin.
|
|
Currently just the feed-poll interval, which used to be a per-feed
|
|
field; it's site-wide now (see apps.feeds.tasks.poll_due_feeds).
|
|
"""
|
|
|
|
id = models.PositiveSmallIntegerField(primary_key=True, default=1)
|
|
fetch_interval_minutes = models.PositiveIntegerField(
|
|
default=60,
|
|
help_text=(
|
|
"How often, in minutes, every feed is polled for new articles. "
|
|
"Can't be set lower than EVECTION_MIN_FETCH_INTERVAL_MINUTES (see .env)."
|
|
),
|
|
)
|
|
|
|
class Meta:
|
|
verbose_name = "Site settings"
|
|
verbose_name_plural = "Site settings"
|
|
|
|
def __str__(self):
|
|
return "Site settings"
|
|
|
|
@classmethod
|
|
def load(cls):
|
|
"""Returns the singleton row, creating it with defaults on first
|
|
use so callers never need to special-case "no row exists yet"
|
|
(e.g. a fresh install whose first poll_due_feeds run hasn't
|
|
created it, and whose admin hasn't visited the settings page)."""
|
|
obj, _ = cls.objects.get_or_create(pk=1)
|
|
return obj
|