From deb0940f5ffa07014872144060580b6c9b079b38 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Sun, 31 May 2026 03:02:34 -0700 Subject: [PATCH] fix(snapshots): honor SNAPSHOTS_PER_PAGE without silent clamping; bump default to 50 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit admin_snapshots.py:571 had min(max(50, SNAPSHOTS_PER_PAGE), 500), and admin_archiveresults.py:501 had min(max(5, SNAPSHOTS_PER_PAGE), 5000). Both clamps silently overrode the configured value — a documented default of 40 was inaccessible in the Snapshot admin, and the ArchiveResult admin also reused the same setting without being mentioned in the docs. - Drop both clamps; admin changelists now use SNAPSHOTS_PER_PAGE as-is. - Bump the default in common.py from 40 to 50 (matches what users were actually seeing in the admin under the old floor). - Add ge=1 validation so non-positive values are rejected at config parse time instead of producing broken pagination. - Update Configuration.md: new default 50, clarify the option drives both Snapshot and ArchiveResult admin changelists plus the public index, and that it must be >= 1. Co-Authored-By: Claude Opus 4.7 (1M context) --- archivebox/config/common.py | 2 +- archivebox/core/admin_archiveresults.py | 2 +- archivebox/core/admin_snapshots.py | 2 +- docs/Configuration.md | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/archivebox/config/common.py b/archivebox/config/common.py index 31e8abf5..f15de884 100644 --- a/archivebox/config/common.py +++ b/archivebox/config/common.py @@ -193,7 +193,7 @@ class ServerConfig(BaseConfigSet): CSRF_TRUSTED_ORIGINS: str = Field(default="") SERVER_SECURITY_MODE: str = Field(default="safe-subdomains-fullreplay") - SNAPSHOTS_PER_PAGE: int = Field(default=40) + SNAPSHOTS_PER_PAGE: int = Field(default=50, ge=1) FOOTER_INFO: str = Field( default="Content is hosted for personal archiving purposes only. Contact server owner for any takedown requests.", ) diff --git a/archivebox/core/admin_archiveresults.py b/archivebox/core/admin_archiveresults.py index d5fb048b..7de662bc 100644 --- a/archivebox/core/admin_archiveresults.py +++ b/archivebox/core/admin_archiveresults.py @@ -498,7 +498,7 @@ class ArchiveResultAdmin(BaseModelAdmin): self.request = request request.archivebox_config = getattr(request, "archivebox_config", None) or get_config() saved_list_per_page = self.list_per_page - self.list_per_page = min(max(5, request.archivebox_config.SNAPSHOTS_PER_PAGE), 5000) + self.list_per_page = request.archivebox_config.SNAPSHOTS_PER_PAGE try: return super().changelist_view(request, extra_context) finally: diff --git a/archivebox/core/admin_snapshots.py b/archivebox/core/admin_snapshots.py index 9b7aaad0..66b9d1b6 100644 --- a/archivebox/core/admin_snapshots.py +++ b/archivebox/core/admin_snapshots.py @@ -568,7 +568,7 @@ class SnapshotAdmin(SearchResultsAdminMixin, ConfigEditorMixin, BaseModelAdmin): requested_per_page = 200 self.list_per_page = min(max(200, requested_per_page), 500) else: - self.list_per_page = min(max(50, request.archivebox_config.SNAPSHOTS_PER_PAGE), 500) + self.list_per_page = request.archivebox_config.SNAPSHOTS_PER_PAGE extra_context = extra_context or {} extra_context["embedded_changelist"] = embedded_changelist extra_context["CONFIG"] = request.archivebox_config diff --git a/docs/Configuration.md b/docs/Configuration.md index 2bcadab0..97e03526 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -424,9 +424,9 @@ More info: --- #### `SNAPSHOTS_PER_PAGE` -**Possible Values:** [`40`]/`100`/... +**Possible Values:** [`50`]/`25`/`100`/`200`/... -Maximum number of Snapshots to render per page on the snapshot list views (both the admin index and the public index). Larger values speed up bulk browsing at the cost of heavier per-request rendering. +Number of rows to render per page on the Snapshot and ArchiveResult list views (admin index, public index, and the Django admin changelists for both models). Lower values reduce per-request render time; higher values speed up bulk browsing at the cost of heavier rendering. Must be ≥ 1. --- #### `FOOTER_INFO`