Private
Public Access
Articles and full HTML bodies accumulated forever, growing the database, search index, and backups without bound. Site settings gets a "Retention days" field (0, the default, keeps everything); a nightly beat task deletes articles fetched longer ago than that in bounded chunks, always keeping anything a user starred or saved for later. Read state and tags cascade with the article and the FTS triggers drop search entries. The dashboard shows the article count and oldest article's age, and docs/install.md covers retention, the readiness check, and SQLite's WAL tuning. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
46 lines
1.7 KiB
Python
46 lines
1.7 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)."
|
|
),
|
|
)
|
|
|
|
retention_days = models.PositiveIntegerField(
|
|
default=0,
|
|
help_text=(
|
|
"Articles older than this many days (by when they were fetched) are "
|
|
"deleted daily, along with everyone's read state and tags for them — "
|
|
"except articles anyone has starred or saved for later. 0 keeps "
|
|
"everything forever."
|
|
),
|
|
)
|
|
|
|
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
|