Skip to content

Sort every view newest first - #288

Merged
yorickdewid merged 1 commit into
mainfrom
feat/default-sort-newest
Jul 27, 2026
Merged

Sort every view newest first#288
yorickdewid merged 1 commit into
mainfrom
feat/default-sort-newest

Conversation

@yorickdewid

Copy link
Copy Markdown
Contributor

Answers "can the predefined filters show the newest items?" — and the answer turned out to be that they weren't showing anything in particular.

What was actually happening

Leaving sort off let GET /inquiry fall back to coalesce(update_date, create_date) DESC. That sounds like recency. It isn't:

           ord_value           | count
-------------------------------+-------
 2026-06-27 10:34:31.474958+00 | 20950   <- the #973 attribution backfill
 2026-07-17 12:28:03.588382+00 |     2

20,950 of 26,671 inquiries share one timestamp, so four rows in five sat in a single tie group, in an order nobody chose and LIMIT/OFFSET does not promise to keep stable between two pages. "Alles" only looked sorted.

The change

sort is no longer nullable. The explorer starts at document_date DESC, every request carries it, and the endpoint's fallback becomes unreachable. Newest first on the one date the table actually shows — so "newest first" is checkable by reading down the Datum column instead of taken on trust. (Sorting on id would be newest-entered, but would make the visible date column look shuffled.)

The Werkbank lanes get it too, where it mattered more: a lane previews the first 8 of the 50 it fetches, so an unsorted fetch meant eight arbitrary rows out of that tie group.

Consequences of there being no unsorted state any more:

  • The sort chip shows only once you deviate from the default. A chip on every screen is furniture, and its × would be a button that does nothing.
  • Clicking a column a second time — in the panel or on the table header — flips the direction instead of switching sorting off.
  • Views saved before today live in localStorage holding sort: null. fromView reads anything unrecognised back onto the default, so an old saved view can't resurrect the old behaviour.

Ordering note

Paging over this is only total once FunderMapsApi #101 adds the primary key as the last ORDER BY key. Until that merges, document_date narrows the ties from one group of 20,950 to groups of roughly three — strictly better than what's on prod now, and independent of it, so this can ship first.

Verification

vue-tsc + eslint clean, pnpm build green, plus two throwaway harnesses (deleted before commit):

  • Logic — all five built-in views and all three Werkbank lanes come out sorted document_date desc and reach the API that way; the default stays out of the URL while a deviation carries both halves; ?sort= absent or nonsense lands on the default; a legacy sort: null saved view is migrated on read; chip appears/clears correctly; every column still round-trips.
  • SSR render — the popover shows the direction row and the "Dit is de standaardvolgorde" note in the default state, and drops the note (keeping the enum caveat) once you pick Status.

🤖 Generated with Claude Code

"Alles" and "Te controleren" looked like they showed recent work. They
showed whatever the API's fallback ordering produced, which is
coalesce(update_date, create_date) DESC -- and the #973 backfill stamped
one identical update_date onto 20,950 of 26,671 inquiries, so four rows
in five sat in a single tie group in an order nobody chose.

The explorer now always sorts. sort is no longer nullable: the query
starts at document_date DESC, every request carries it, and the fallback
is simply unreachable. Newest first on the one date the table shows, so
the claim can be checked by reading down the Datum column rather than
taken on trust.

The Werkbank lanes get it too, where it shows more: a lane previews the
first eight of the fifty it fetches, so an unsorted fetch meant eight
arbitrary rows out of that same tie group.

Falling out of "there is no unsorted state": the sort chip appears only
once you deviate from the default (a chip on every screen is furniture,
and its cross would do nothing), clicking a column twice flips direction
instead of switching sorting off, and views saved before today -- which
live in localStorage with sort: null -- are read back onto the default
rather than resurrecting the old behaviour.

Paging over this is only total once FunderMapsApi #101 lands the primary
key as the last ORDER BY key. Until then document_date narrows the ties
from one group of 20,950 to groups of about three, which is strictly
better than what shipped before it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@yorickdewid
yorickdewid merged commit bd8b22e into main Jul 27, 2026
1 check passed
@yorickdewid
yorickdewid deleted the feat/default-sort-newest branch July 27, 2026 10:32
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.

1 participant