Skip to content

fix(support): onboardingstap toont de eerste acceptatie, niet de laatste - #52

Merged
onder-ates merged 1 commit into
mainfrom
fix/support-eerste-acceptatie
Aug 3, 2026
Merged

fix(support): onboardingstap toont de eerste acceptatie, niet de laatste#52
onder-ates merged 1 commit into
mainfrom
fix/support-eerste-acceptatie

Conversation

@onder-ates

@onder-ates onder-ates commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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:

Voorwaarden, privacy en verwerkersovereenkomst — 30 jul 22:36

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 via distinct on (document_type) order by accepted_at desc.

Bewijs

Read-only tegen productie, oude en nieuwe berekening naast elkaar voor Nielsen:

Waarde
Ingeschreven 23 jul 18:52:14.192
Stap nu 30 jul 20:36:28 ❌
Stap na fix 23 jul 18:52:14.724 ✅ (0,53 s na inschrijving)
Juridisch blok na fix alle drie 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 — alleen support_school_detail vervangen (create or replace, zelfde signatuur). Geen tabelwijziging. Terugdraaien: de vorige functieversie terugzetten.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a support-oriented school details view containing instructor, access, confirmation, legal acceptance, onboarding, subscription, CBR, and usage information.
    • Added accurate acceptance tracking, including document versions and relevant timestamps.
    • Restricted access to authorized service operations.

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>
@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
ribba-pro Ready Ready Preview Aug 3, 2026 10:36pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds public.support_school_detail(uuid), a stable security definer SQL function. It returns school support data as JSONB, including legal acceptance, onboarding, subscription, CBR, and usage details. Execution is restricted to service_role.

Changes

Support school detail

Layer / File(s) Summary
Support data collection
supabase/migrations/20260803220000_support_eerste_acceptatie.sql
The function gathers school, instructor, authentication, legal, onboarding, subscription, CBR, and operational data. It separates first legal acceptances from latest legal acceptances.
JSON response and access control
supabase/migrations/20260803220000_support_eerste_acceptatie.sql
The function builds school, legal, subscription, CBR, aggregate, and ordered onboarding JSON sections. It documents the function and grants execution only to service_role.

Estimated code review effort: 4 (Complex) | ~45 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed De titel beschrijft nauwkeurig de hoofdwijziging: de onboardingstap gebruikt de eerste acceptatie in plaats van de laatste.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/support-eerste-acceptatie

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 91cec9c and 0f302e6.

📒 Files selected for processing (1)
  • supabase/migrations/20260803220000_support_eerste_acceptatie.sql

Comment on lines +60 to +65
-- 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ 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.

@onder-ates
onder-ates merged commit 0fb0e1d into main Aug 3, 2026
3 checks passed
@onder-ates
onder-ates deleted the fix/support-eerste-acceptatie branch August 3, 2026 23:04
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