Back to the pile

Ledger that hides its newest rows

Page one starts ten days in the past, and the last page is blank. Every transaction is in the database.

nextSoft~15 min
1

Fresh from the oven

Clone it down and have a look around.

$git clone https://github.com/loaf-crumbs/ledger-hides-newest-rows.git
2

The scenario

An account ledger lists recent transactions, newest first, ten to a page, with a simple "Newer / Older" pager at the bottom. There are twenty-five transactions in the database and the header promises "Showing 1–10 of 25" when you land on the first page. Except page one doesn't begin where it should. The most recent transaction — today's payout, the one you'd expect at the very top — is missing, and so are the nine entries behind it. The list opens partway down the timeline, already a week and a half in the past. Page through to the end and the count never adds up: the final page comes back empty, an entire page of nothing hanging off the bottom of the ledger. Hit `/api/transactions?page=1` directly and the same short, shifted window comes back, so this isn't the table rendering or the pager buttons. Nothing errors, nothing 500s, and every row that does show is correct and in the right order. The data is all there in `lib/db.js` — twenty-five rows, complete. It's purely a question of which slice each page hands back.
3

What done looks like

- Page one shows the ten most recent transactions, newest at the top - Every transaction appears on exactly one page — none skipped, none repeated - The last page shows the oldest transactions and is never blank - The "Showing X–Y of 25" count matches the rows actually on the page
4

Stuck?

Peek if you need to — they get more specific as you go.

5

Taste test

Send it in when you’re ready. We’ll see if it’s tasty.

When you've got the flag, paste it here.

No attempts yet.