Skip to content

Conversation

@codeunia-dev
Copy link
Owner

@codeunia-dev codeunia-dev commented Nov 19, 2025

  • Add service role Supabase client to events export endpoint to bypass RLS when querying registrations
  • Fetch user profiles for registrations with user_id to populate accurate name and email data
  • Update CSV export to display profile name and email when available, falling back to registration data
  • Apply same profile data logic to hackathons registration export for consistency
  • Rename server client import to avoid naming conflicts with service role client
  • Improves data accuracy in exported registrations by using authoritative profile information

Authored by: @akshay0611

Summary by CodeRabbit

  • Bug Fixes
    • Registration exports now display user profile names and emails when available, with fallbacks to previously recorded information.
    • Improved date formatting for registration timestamps and payment amount display in CSV exports.
    • Enhanced error handling with more specific response codes for export requests.

…role client for events

- Add service role Supabase client to events export endpoint to bypass RLS when querying registrations
- Fetch user profiles for registrations with user_id to populate accurate name and email data
- Update CSV export to display profile name and email when available, falling back to registration data
- Apply same profile data logic to hackathons registration export for consistency
- Rename server client import to avoid naming conflicts with service role client
- Improves data accuracy in exported registrations by using authoritative profile information
@vercel
Copy link

vercel bot commented Nov 19, 2025

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

Project Deployment Preview Comments Updated (UTC)
codeunia Building Building Preview Comment Nov 19, 2025 7:29am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 19, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Both registration export endpoints are enhanced to enrich CSV output with user profile data. The events endpoint introduces service-role authentication and company membership verification, while the hackathons endpoint adds simpler profile enrichment. Both now fetch user profiles and map profile fields to CSV display columns.

Changes

Cohort / File(s) Summary
Registration export profile enrichment
app/api/events/[slug]/registrations/export/route.ts, app/api/hackathons/[id]/registrations/export/route.ts
Both endpoints now fetch user profiles for registrations with user_id and enrich CSV output with profile-derived display names and emails. Events endpoint introduces service-role client helper for RLS bypass, server-authenticated client for user lookup, event fetch with company membership verification, and granular error handling (401/403/404/500). Hackathons endpoint adds conditional profile retrieval and display field mapping. Both update CSV columns to use displayName and displayEmail with fallbacks to registration fields.

Sequence Diagram

sequenceDiagram
    actor Client
    participant Endpoint as Export Endpoint
    participant Auth as Auth Client
    participant DB as Supabase DB
    participant ServiceRole as Service-Role Client

    Client->>Endpoint: GET /registrations/export
    Endpoint->>Auth: Get authenticated user (events) / Verify session (hackathons)
    alt Auth Error
        Auth-->>Endpoint: Error / No user
        Endpoint-->>Client: 401 Unauthorized
    else Auth Success
        Auth-->>Endpoint: User / Session confirmed
        Endpoint->>DB: Fetch event/hackathon by slug/id
        alt Not found
            DB-->>Endpoint: No event/hackathon
            Endpoint-->>Client: 404 Not Found
        else Found
            alt Company membership verification (events only)
                Endpoint->>DB: Check membership
                alt No access
                    DB-->>Endpoint: Not member
                    Endpoint-->>Client: 403 Forbidden
                else Has access
                    DB-->>Endpoint: Confirmed
                end
            end
            Endpoint->>ServiceRole: Fetch registrations (events: service-role for RLS bypass)
            ServiceRole-->>Endpoint: Registrations list
            Endpoint->>DB: Extract user_ids from registrations
            Endpoint->>DB: Fetch profiles for user_ids
            DB-->>Endpoint: Profile data
            rect rgb(220, 240, 255)
                note over Endpoint: Map profile fields to display data<br/>(displayName, displayEmail)
            end
            Endpoint->>Endpoint: Generate CSV with enriched columns
            Endpoint-->>Client: CSV file
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Events endpoint: Introduces new authentication pattern (service-role client helper), company membership verification logic, and granular error handling—requires careful verification of access control flow
  • Hackathons endpoint: Simpler profile enrichment but pattern consistency with events should be confirmed
  • Both files: Fallback logic for display fields (profile data vs. registration data) should be verified for correctness and edge cases (null/empty profiles)

Poem

🐰 Profiles now dance with registrations true,
CSV rows enriched with names anew,
Service roles bypass the locks so tight,
Display names gleaming, emails bright!
From events to hackathons, the data flows—
A registration feast that perfectly grows! 🎉

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/hackathon

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7c0a82e and 548b5f4.

📒 Files selected for processing (2)
  • app/api/events/[slug]/registrations/export/route.ts (5 hunks)
  • app/api/hackathons/[id]/registrations/export/route.ts (3 hunks)

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 and usage tips.

@codeunia-dev codeunia-dev merged commit ab5cea5 into main Nov 19, 2025
2 of 4 checks passed
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.

3 participants