Skip to content

Count the rows an ingest write actually changed - #51

Merged
DanialBeg merged 2 commits into
mainfrom
fix/deadline-ingest-verifies-writes
Sep 28, 2026
Merged

DanialBeg merged 2 commits into
mainfrom
fix/deadline-ingest-verifies-writes

Conversation

@DanialBeg

Copy link
Copy Markdown
Member

The apply run reported wrote 935/935 and changed nothing.

public.colleges is RLS read-only in normal operation, so the anon key's UPDATEs matched zero rows. PostgREST does not call that an error — an RLS-filtered update is a 204 with no error, indistinguishable from one that succeeded — so the loop counted 935 accepted requests as 935 written rows. The database still held 46 regular-decision dates afterwards and not one row carried the new verified_at.

Two changes.

The write verifies itself

.select() on the update, so the changed rows come back and can be counted, and the loop stops on the first that changed none rather than grinding through 935 silent no-ops. The message names the cause and what to do about it.

Applying goes through SQL run as the owner

--apply only works bracketed by a temporary policy letting anon update colleges — and the anon key is public in the JS bundle, so for as long as that policy exists anyone can rewrite the table. A once-a-cycle write does not justify the window.

emit-sql.mjs runs the same selection and writes nothing. It prints the changes as one statement to paste into the SQL editor, where it executes as the project owner:

  • one statement, so it lands whole or not at all
  • every column written through coalesce(new, existing), so a curated value survives even if the selection logic were wrong
  • no policy to add, none to forget to drop

--apply stays, with the RLS procedure now documented and the failure loud instead of silent.

This is how the September 2026 run was applied

regular_decision:  46 → 977
early_action:      16 → 392
early_decision:    13 → 218
stamped:                935

The 46 curated rows are untouched — Stanford still Jan 2, Georgetown still Jan 10, Wisconsin still Feb 1 — so the 13 places the grid disagrees are still there to settle by hand.

Parser tests: 8 passing, unchanged.

The apply run reported "wrote 935/935" and changed nothing.

public.colleges is RLS read-only in normal operation, so the anon key's
UPDATEs matched zero rows. PostgREST does not call that an error — an
RLS-filtered update is a 204 with no error, exactly like one that succeeded —
so the loop counted 935 accepted requests as 935 written rows. The database
still held 46 regular-decision dates afterwards and not one row carried the
new verified_at.

So the write now asks for the changed rows back and counts those, and stops on
the first that changed none rather than grinding through 935 silent no-ops.
The message says what is actually wrong and what to do about it.

scripts/ingest-colleges already documented the temporary anon write policy
this needs, bracketing the run and dropped straight after; this one did not.
Now it does.
--apply needs a policy letting anon update colleges, and anon is public in the
JS bundle: for as long as it exists anyone can rewrite the table. A one-off
annual write does not justify that window.

emit-sql.mjs runs the same selection and writes no rows — it prints the
changes as one statement to paste into the SQL editor, where it executes as
the project owner. One statement, so it lands whole or not at all, and every
column goes through coalesce(new, existing) so a curated value survives even
if the selection were wrong.

This is how the September 2026 run was applied: 935 rows, real
regular-decision dates from 46 colleges to 977, with the 13 grid
disagreements left for someone to settle by hand.
@vercel

vercel Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
webapp Ready Ready Preview Sep 28, 2026 3:23am UTC

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying timeline-prototype with  Cloudflare Pages  Cloudflare Pages

Latest commit: aa7fe06
Status: ✅  Deploy successful!
Preview URL: https://3df44de9.timeline-prototype.pages.dev
Branch Preview URL: https://fix-deadline-ingest-verifies.timeline-prototype.pages.dev

View logs

@DanialBeg
DanialBeg merged commit 1df1925 into main Sep 28, 2026
5 checks passed
@DanialBeg
DanialBeg deleted the fix/deadline-ingest-verifies-writes branch September 28, 2026 03:24

This branch was successfully deployed

1 active deployment
Preview — aa7fe062 Deployed Sep 28, 2026 by vercel[bot]
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