fix(support): onboardingstap toont de eerste acceptatie, niet de laatste - #52
Conversation
De stap "Voorwaarden, privacy en verwerkersovereenkomst" nam max(accepted_at).
Dat is de laatste acceptatie, en die schuift vooruit zodra een documentversie
wordt gebumpt en iedereen opnieuw moet accepteren.
Gemeten op Rijschool Nielsen: ingeschreven 23 juli 20:52, alle drie de
documenten diezelfde seconde geaccepteerd. Na de DPA-bump van eind juli
accepteerden ze op 30 juli opnieuw. Het scherm meldde daardoor dat ze de
voorwaarden pas een week ná inschrijving hadden geaccepteerd — precies het
soort gat waar je een verkeerde conclusie uit trekt ("ze twijfelden een week").
Een onboardingstap beantwoordt "wanneer deed deze rijschool dit voor het
eerst": per document de eerste keer, en daarvan de laatste, want de stap is
pas af als alle drie ooit zijn geaccepteerd. Na de fix staat Nielsen op 0,53
seconden na inschrijving.
Het juridische blok houdt bewust de laatste acceptatie: daar is de vraag juist
welke versie nu geldt. Twee vragen, twee berekeningen, dezelfde tabel.
Meegenomen in hetzelfde blok: de getoonde versie kwam uit
max(document_version) — de alfabetisch hoogste versietekst, niet de versie van
de laatste acceptatie. Dat gaat nu goed doordat '2026-07-v1' alfabetisch én
chronologisch gelijk loopt, maar dat is een aanname over een tekstformaat.
Nu via distinct on (document_type) order by accepted_at desc.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds ChangesSupport school detail
Estimated code review effort: 4 (Complex) | ~45 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@supabase/migrations/20260803220000_support_eerste_acceptatie.sql`:
- Around line 60-65: Update the juridisch_eerste onboarding calculation to
consider only the three required document types and return NULL unless each has
a first acceptance; use this gated value when setting the onboarding step. Add
or update migration cases covering zero, one, two, and three required
acceptances, plus a later reacceptance, ensuring only completion of all three
establishes the initial onboarding timestamp.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 369a4522-8ddf-4706-8b92-ce04e528a79e
📒 Files selected for processing (1)
supabase/migrations/20260803220000_support_eerste_acceptatie.sql
| -- Eerste acceptatie per document; voedt de onboardingstap. | ||
| juridisch_eerste as ( | ||
| select la.document_type, min(la.accepted_at) as wanneer | ||
| from public.legal_acceptances la | ||
| where la.school_id = p_school_id | ||
| group by la.document_type |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Require all three documents before setting the onboarding time.
juridisch_eerste contains only document types that already have an acceptance record. Line 188 therefore returns a timestamp when only one or two documents exist. It can also include a document type outside the required onboarding set.
Filter to the three required document types. Return NULL unless all three have a first acceptance. Use that gated value for the onboarding step. Add cases for zero through three acceptances and for a later reacceptance.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@supabase/migrations/20260803220000_support_eerste_acceptatie.sql` around
lines 60 - 65, Update the juridisch_eerste onboarding calculation to consider
only the three required document types and return NULL unless each has a first
acceptance; use this gated value when setting the onboarding step. Add or update
migration cases covering zero, one, two, and three required acceptances, plus a
later reacceptance, ensuring only completion of all three establishes the
initial onboarding timestamp.
Gevonden bij het uitleggen van de onboardingcijfers: het scherm vertelde over Rijschool Nielsen een verhaal dat niet klopte.
Wat er mis was
De stap "Voorwaarden, privacy en verwerkersovereenkomst" nam
max(accepted_at)— de laatste acceptatie. Die schuift vooruit zodra een documentversie wordt gebumpt en iedereen opnieuw moet accepteren.Nielsen schreef zich in op 23 juli 20:52 en accepteerde alle drie de documenten diezelfde seconde (
v2026-04-v1). Na de DPA-bump van eind juli accepteerden ze op 30 juli opnieuw (v2026-07-v1). Het onboardingscherm meldde daardoor:Een week ná inschrijving, terwijl er in werkelijkheid geen halve seconde tussen zat. Precies het soort gat waar je een verkeerde conclusie uit trekt: "ze hebben een week zitten twijfelen."
De fix
Een onboardingstap beantwoordt "wanneer deed deze rijschool dit voor het eerst". Dus: per document de eerste keer, en daarvan de laatste — de stap is pas af als alle drie ooit zijn geaccepteerd.
Het juridische blok eronder houdt bewust de laatste acceptatie: daar is de vraag juist welke versie nu geldt en wanneer die is aanvaard. Twee vragen, twee berekeningen, dezelfde tabel.
Meegenomen in hetzelfde blok
De getoonde versie kwam uit
max(document_version): de alfabetisch hoogste versietekst, niet de versie die bij de laatste acceptatie hoort. Dat gaat vandaag goed omdat'2026-07-v1'alfabetisch én chronologisch gelijk loopt — maar dat is een aanname over een tekstformaat, geen feit. Nu viadistinct on (document_type) order by accepted_at desc.Bewijs
Read-only tegen productie, oude en nieuwe berekening naast elkaar voor Nielsen:
2026-07-v1, 30 jul ✅ (ongewijzigd)227 tests groen. Geen applicatiecode gewijzigd — alleen de databasefunctie, dus de bestaande tests raken dit pad niet; het bewijs is de meting hierboven.
Migratie
20260803220000— alleensupport_school_detailvervangen (create or replace, zelfde signatuur). Geen tabelwijziging. Terugdraaien: de vorige functieversie terugzetten.🤖 Generated with Claude Code
Summary by CodeRabbit