Use keyset pagination for the stream (C4)

The stream did a COUNT(*) and OFFSET slice on every request, ordered by
a non-unique (published_at, fetched_at) — deep pages got slower and
articles sharing a timestamp could repeat or vanish across pages.

It now orders by (Coalesce(published_at, fetched_at), id) and pages with
before/after cursors, fetching one extra row to know whether another
page exists instead of counting. Pagination links also keep the feed
scope, which the old links silently dropped.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ksmithandClaude Sonnet 5.5 committed 2026-11-01 08:51:20 -07:00
1 parent 70b0d4f277
commit 8d2900424a
3 files changed
+156 -16

No files matched your search

+4 -4
View File
@@ -10,10 +10,10 @@
</ul>
<nav class="pagination">
{% if has_previous_page %}
<a href="?filter={{ active_filter }}{% if active_tag %}&tag={{ active_tag.pk }}{% endif %}&page={{ page|add:"-1" }}">&larr; Newer</a>
{% if has_newer_page %}
<a href="?{{ newer_qs }}">&larr; Newer</a>
{% endif %}
{% if has_next_page %}
<a href="?filter={{ active_filter }}{% if active_tag %}&tag={{ active_tag.pk }}{% endif %}&page={{ page|add:"1" }}">Older &rarr;</a>
{% if has_older_page %}
<a href="?{{ older_qs }}">Older &rarr;</a>
{% endif %}
</nav>