Skip to content

fix(posts): sort by published date with grabbed date fallback - #182

Merged
icco merged 1 commit into
mainfrom
fix/chronological-post-order
Oct 11, 2026
Merged

icco merged 1 commit into
mainfrom
fix/chronological-post-order

Conversation

@icco

@icco icco commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Why

New posts are still being ingested, but PostgreSQL sorts null publication dates first, filling the first page with undated posts. Sort post, bot, and tag listings newest-first by COALESCE(published_at, created_at), with an ID tie-breaker and a matching index.

Verified: all 312 tests passed against disposable PostgreSQL, plus lint/typecheck, production build, and feed validation. Regression coverage checks fallback dates, publication-date precedence, pagination, and deleted posts.

Risks

The startup migration rebuilds the chronological index and can briefly block writes while it runs. Undated posts now appear according to when they were grabbed.

Copilot AI balanced review requested due to automatic review settings October 10, 2026 16:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The queries, index, migration metadata, and regression coverage consistently implement the intended ordering.

0 open findings

What changed in this PR

Updates post ordering to use publication time with ingestion time as fallback.

Changes:

  • Applies consistent deterministic ordering to bot, tag, and global listings.
  • Adds a matching partial database index and migration.
  • Adds regression coverage for fallback ordering, ties, pagination, and deleted entries.
File Description
src/​lib/​schema.ts Defines the chronological composite index.
src/​lib/​db.ts Shares the new ordering across listing queries.
src/​lib/​__tests__/​db.test.ts Tests ordering and pagination behavior.
drizzle/​0021_chronological_post_order.sql Rebuilds the index.
drizzle/​meta/​0021_snapshot.json Records the updated schema snapshot.
drizzle/​meta/​_journal.json Registers migration 0021.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@icco
icco merged commit b150476 into main Oct 11, 2026
10 checks passed
@icco
icco deleted the fix/chronological-post-order branch October 11, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants