Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@devkiran
Copy link
Collaborator

@devkiran devkiran commented Oct 17, 2025

Summary by CodeRabbit

  • Chores

    • Updated web and database dependencies and upgraded the Prisma toolchain; narrowed Prisma preview features.
  • Bug Fixes / UI

    • Streamlined OG image generation, switched the top medallion asset to JPG, and improved font loading for consistent visuals.
  • Backend

    • Switched server-side rewind retrieval to a dedicated API call and return 404 when not found.
  • Frontend / Public API

    • Replaced rewindId with partnerId across sharing flows and schemas, updating URLs and modal props.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Contributor

vercel bot commented Oct 17, 2025

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

Project Deployment Review Updated (UTC)
dub Ready Ready Preview Dec 23, 2025 9:13pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 17, 2025

📝 Walkthrough

Walkthrough

Dependency bumps in apps/web and packages/prisma; Prisma generator previewFeatures narrowed to ["driverAdapters"]; OG image route refactored to use the shared getPartnerRewind/Planetscale flow, loads fonts from the filesystem, switches medallion to .jpg, removes export const runtime = "edge", and several UI components/props renamed from rewindId -> partnerId. A new partnerId field was added to the PartnerRewind zod schema and SQL query.

Changes

Cohort / File(s) Summary
App dependency updates
apps/web/package.json
Bumped @next-auth/prisma-adapter ^1.0.5 → ^1.0.7 and @prisma/nextjs-monorepo-workaround-plugin ^6.0.1 → ^6.19.1
Prisma package upgrades
packages/prisma/package.json
Upgraded @planetscale/database 1.18.x → 1.19.0; @prisma/adapter-planetscale, @prisma/client, and dev prisma 5.18.x → 6.19.1
Prisma schema generator config
packages/prisma/schema/schema.prisma
Reformatted provider spacing; reduced generator.client.previewFeatures from ["fullTextSearch","fullTextIndex","driverAdapters","prismaSchemaFolder","omitApi"] to ["driverAdapters"]
OG image route & data access
apps/web/app/api/og/partner-rewind/route.tsx
Replaced inline Prisma Edge/raw SQL with shared getPartnerRewind/Planetscale retrieval; removed export const runtime = "edge"; switched font loading to filesystem readFile and medallion asset to .jpg; removed legacy in-file retrieval; updated error/404 handling and response shaping
Partner rewind query
apps/web/lib/api/partners/get-partner-rewind.ts
SQL/selection extended to include pr.partnerId in returned row
Zod schema update
apps/web/lib/zod/schemas/partners.ts
Added partnerId: z.string() to PartnerRewindSchema
UI prop renames (rewindId → partnerId)
apps/web/app/(ee)/partners.dub.co/(dashboard)/rewind/2025/rewind.tsx, apps/web/app/(ee)/partners.dub.co/(dashboard)/rewind/2025/share-rewind-modal.tsx
Replaced rewindId parameter/prop with partnerId everywhere the share modal and OG image URL are constructed/consumed; updated inner prop types and callers to pass partnerId

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant OGRoute as OG Route (/api/og/partner-rewind)
    participant API as getPartnerRewind
    participant DB as PlanetScale DB
    participant Renderer as Image Renderer

    Client->>OGRoute: GET /api/og/partner-rewind?partnerId=<id>
    OGRoute->>API: getPartnerRewind(partnerId)
    API->>DB: parameterized SELECT (bind partnerId)
    DB-->>API: row or empty
    API-->>OGRoute: partner rewind row or null
    alt row found
        OGRoute->>OGRoute: read fonts from filesystem (Inter, Satoshi) & load medallion.jpg
        OGRoute->>Renderer: render OG image using row data
        Renderer-->>OGRoute: image bytes
        OGRoute-->>Client: 200 OK (image)
    else no row
        OGRoute-->>Client: 404 / null response
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • devkiran

Poem

🐇
I hopped through code to fetch a friend,
Fonts in my paws and SQL to send.
Medallion bright in JPG cheer,
Partner IDs now loud and clear.
— a rabbit, nibbling on the deploy gear

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Upgrade Prisma and related dependencies to v6.x.x' accurately describes the main change in the pull request, which involves updating Prisma from v5.x.x to v6.x.x and related dependency versions across multiple package.json files.
✨ 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 upgrade-prisma

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 92f1034 and 97726e3.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • apps/web/app/(ee)/partners.dub.co/(dashboard)/rewind/2025/rewind.tsx
  • apps/web/app/(ee)/partners.dub.co/(dashboard)/rewind/2025/share-rewind-modal.tsx
  • apps/web/app/api/og/partner-rewind/route.tsx
  • apps/web/lib/api/partners/get-partner-rewind.ts
  • apps/web/lib/zod/schemas/partners.ts
  • apps/web/package.json
  • packages/prisma/package.json
  • packages/prisma/schema/schema.prisma
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: TWilson023
Repo: dubinc/dub PR: 2935
File: packages/prisma/schema/workspace.prisma:21-36
Timestamp: 2025-10-06T15:48:45.956Z
Learning: In the Dub repository (dubinc/dub), Prisma schema changes are not managed with separate migration files. Do not flag missing Prisma migration files when schema changes are made to files like `packages/prisma/schema/workspace.prisma` or other schema files.
📚 Learning: 2025-08-16T11:14:00.667Z
Learnt from: devkiran
Repo: dubinc/dub PR: 2754
File: apps/web/lib/partnerstack/schemas.ts:47-52
Timestamp: 2025-08-16T11:14:00.667Z
Learning: The PartnerStack API always includes the `group` field in partner responses, so the schema should use `.nullable()` rather than `.nullish()` since the field is never omitted/undefined.

Applied to files:

  • apps/web/lib/zod/schemas/partners.ts
📚 Learning: 2025-10-06T15:48:45.956Z
Learnt from: TWilson023
Repo: dubinc/dub PR: 2935
File: packages/prisma/schema/workspace.prisma:21-36
Timestamp: 2025-10-06T15:48:45.956Z
Learning: In the Dub repository (dubinc/dub), Prisma schema changes are not managed with separate migration files. Do not flag missing Prisma migration files when schema changes are made to files like `packages/prisma/schema/workspace.prisma` or other schema files.

Applied to files:

  • apps/web/package.json
  • packages/prisma/package.json
  • packages/prisma/schema/schema.prisma
📚 Learning: 2025-09-24T16:13:00.387Z
Learnt from: TWilson023
Repo: dubinc/dub PR: 2872
File: packages/prisma/schema/partner.prisma:151-153
Timestamp: 2025-09-24T16:13:00.387Z
Learning: In the Dub codebase, Prisma schemas use single-column indexes without brackets (e.g., `@index(partnerId)`) and multi-column indexes with brackets (e.g., `@index([programId, partnerId])`). This syntax pattern is consistently used throughout their schema files and works correctly with their Prisma version.

Applied to files:

  • apps/web/package.json
  • packages/prisma/schema/schema.prisma
📚 Learning: 2025-10-28T19:17:28.085Z
Learnt from: TWilson023
Repo: dubinc/dub PR: 2985
File: apps/web/app/(ee)/api/network/programs/[programSlug]/route.ts:20-27
Timestamp: 2025-10-28T19:17:28.085Z
Learning: In this codebase, Prisma's extendedWhereUnique feature is enabled (or Prisma 5.x is used), allowing findUniqueOrThrow to accept additional non-unique filters alongside unique fields like slug. This pattern is valid and acceptable.

Applied to files:

  • packages/prisma/schema/schema.prisma
📚 Learning: 2025-10-15T01:52:37.048Z
Learnt from: steven-tey
Repo: dubinc/dub PR: 2958
File: apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/members/page-client.tsx:270-303
Timestamp: 2025-10-15T01:52:37.048Z
Learning: In React components with dropdowns or form controls that show modals for confirmation (e.g., role selection, delete confirmation), local state should be reverted to match the prop value when the modal is cancelled. This prevents the UI from showing an unconfirmed change. The solution is to either: (1) pass an onClose callback to the modal that resets the local state, or (2) observe modal visibility state and reset on close. Example context: RoleCell component in apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/members/page-client.tsx where role dropdown should revert to user.role when UpdateUserModal is cancelled.

Applied to files:

  • apps/web/app/(ee)/partners.dub.co/(dashboard)/rewind/2025/share-rewind-modal.tsx
🔇 Additional comments (12)
apps/web/package.json (1)

35-38: LGTM! Dependency versions aligned with Prisma 6 upgrade.

The dependency updates are correct:

  • @next-auth/prisma-adapter@^1.0.7 is compatible with Prisma 6 (peer dependency allows >=2.26.0)
  • @prisma/nextjs-monorepo-workaround-plugin@^6.19.1 matches the Prisma client version in the monorepo
apps/web/lib/api/partners/get-partner-rewind.ts (1)

23-25: LGTM! partnerId added to query results.

The addition of pr.partnerId to the SELECT list correctly extends the query results to include the partner identifier, aligning with the updated PartnerRewindSchema that now requires this field.

packages/prisma/package.json (1)

17-23: LGTM! Prisma 6 upgrade properly coordinated.

All Prisma-related packages are correctly upgraded to v6.19.1:

  • @prisma/client, @prisma/adapter-planetscale, and prisma CLI all at 6.19.1 (matching versions required for adapter compatibility)
  • @planetscale/database updated to 1.19.0 (compatible minor update)
apps/web/lib/zod/schemas/partners.ts (1)

345-357: LGTM! Schema extended with required partnerId field.

The addition of partnerId: z.string() to PartnerRewindSchema correctly extends the schema to include the partner identifier as a required field, maintaining consistency with the updated data flow throughout the application.

packages/prisma/schema/schema.prisma (1)

7-10: LGTM! Preview features correctly updated for Prisma 6.

The previewFeatures array is correctly reduced to ["driverAdapters"] only. In Prisma 6, the following features became generally available and no longer require preview flags:

  • fullTextSearch and fullTextIndex (GA in Prisma 6.0)
  • omitApi (GA in Prisma 6.2.0)
  • prismaSchemaFolder (GA in Prisma 6.7.0)

The driverAdapters feature remains as a preview feature in Prisma 6.19 and must be retained since the codebase uses the PlanetScale adapter (packages/prisma/edge.ts).

Based on learnings, Prisma schema changes in this repository are not managed with separate migration files.

apps/web/app/(ee)/partners.dub.co/(dashboard)/rewind/2025/rewind.tsx (1)

63-66: LGTM! Hook parameter correctly updated to use partnerId.

The useShareRewindModal hook now receives partnerId: partnerRewind.partnerId instead of the previous rewindId, correctly aligning with the schema changes where PartnerRewindSchema now includes the partnerId field returned by the updated query.

apps/web/app/(ee)/partners.dub.co/(dashboard)/rewind/2025/share-rewind-modal.tsx (3)

7-10: LGTM! Type definition updated to use partnerId.

The ShareRewindModalInnerProps interface correctly changes from rewindId to partnerId, aligning with the broader refactoring across the application.


25-29: LGTM! Function signature and URL construction updated.

The function parameters and imageUrl construction correctly use partnerId instead of rewindId, maintaining consistency with the updated API route expectations.


58-58: LGTM! Image source URL updated to use partnerId.

The img element's src attribute correctly uses partnerId in the URL search parameters, ensuring the OG image is fetched with the updated parameter name.

apps/web/app/api/og/partner-rewind/route.tsx (3)

1-12: Verify runtime change implications: Edge → Node.js.

The removal of export const runtime = "edge" changes this route from Edge Runtime to Node.js Runtime, enabling filesystem access for font loading. This is a significant architectural change with implications:

Benefits:

  • Enables direct filesystem access via readFile (Edge Runtime doesn't support fs module)
  • Simplifies font loading (no need to fetch from URLs)

Tradeoffs:

  • Edge Runtime typically has faster cold starts and lower latency
  • Node.js Runtime has different resource limits and pricing implications on Vercel
  • Other OG routes (analytics, program) remain on Edge Runtime with fetch-based font loading

Ensure this runtime change is intentional and acceptable for production workloads.


27-42: LGTM! Parameter renamed and API integration improved.

The changes correctly:

  • Rename the request parameter from rewindId to partnerId (line 27)
  • Update error messages to reference partnerId (line 33)
  • Delegate data fetching to the getPartnerRewind API function (line 37), providing cleaner separation of concerns

The error handling for missing partner rewinds is appropriate with a 404 response.


111-111: Image format changed from PNG to JPG for medallion asset.

The asset URL now references a JPG file at https://assets.dub.co/misc/partner-rewind-2025/top-medallion.jpg, which is accessible and properly formatted.


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.

@socket-security
Copy link

socket-security bot commented Oct 17, 2025

@steven-tey steven-tey marked this pull request as ready for review December 23, 2025 19:44
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 92f1034 and dfb1342.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • apps/web/package.json
  • packages/prisma/package.json
  • packages/prisma/schema/schema.prisma
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: TWilson023
Repo: dubinc/dub PR: 2935
File: packages/prisma/schema/workspace.prisma:21-36
Timestamp: 2025-10-06T15:48:45.956Z
Learning: In the Dub repository (dubinc/dub), Prisma schema changes are not managed with separate migration files. Do not flag missing Prisma migration files when schema changes are made to files like `packages/prisma/schema/workspace.prisma` or other schema files.
📚 Learning: 2025-10-06T15:48:45.956Z
Learnt from: TWilson023
Repo: dubinc/dub PR: 2935
File: packages/prisma/schema/workspace.prisma:21-36
Timestamp: 2025-10-06T15:48:45.956Z
Learning: In the Dub repository (dubinc/dub), Prisma schema changes are not managed with separate migration files. Do not flag missing Prisma migration files when schema changes are made to files like `packages/prisma/schema/workspace.prisma` or other schema files.

Applied to files:

  • packages/prisma/schema/schema.prisma
🔇 Additional comments (1)
packages/prisma/package.json (1)

21-23: LGTM!

The prisma CLI version is correctly aligned with @prisma/client at 6.19.1.

Comment on lines 7 to 9
generator client {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch", "fullTextIndex", "driverAdapters", "prismaSchemaFolder", "omitApi"]
provider = "prisma-client-js"
}
Copy link
Contributor

@coderabbitai coderabbitai bot Dec 23, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

Prisma 6 preview features general availability GA release notes

💡 Result:

Prisma 6 promoted the following Preview features to General Availability (GA):

  • fullTextIndex. [1]
  • fullTextSearch — promoted to GA for MySQL; if you used it with PostgreSQL you must switch to the renamed preview flag fullTextSearchPostgres. [1][2]

Sources: Prisma upgrade guide and Prisma changelog. [1] https://www.prisma.io/docs/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-6 [2] https://www.prisma.io/changelog


🌐 Web query:

Prisma 6 driverAdapters preview feature status generally available

💡 Result:

As of Dec 23, 2025 the driverAdapters feature in Prisma 6 is still a Preview feature (not generally available). See the Prisma 6 release notes and docs which instruct enabling previewFeatures = ["driverAdapters"] and describe it as Preview. [1][2][3]

Sources

  • Prisma 6.9.0 release announcement (notes driverAdapters as a Preview flag). [1]
  • Prisma docs on using Prisma without Rust engines (shows driverAdapters as a preview feature). [2]
  • Prisma 6.10.0 release notes (continued Preview status and driver-adapter work). [3]

🏁 Script executed:

cd packages/prisma/schema && git show HEAD:schema.prisma | head -20

Repository: dubinc/dub

Length of output: 227


🏁 Script executed:

git show HEAD:packages/prisma/schema/schema.prisma | head -20

Repository: dubinc/dub

Length of output: 475


🏁 Script executed:

git diff HEAD~1 HEAD -- packages/prisma/schema/schema.prisma | head -50

Repository: dubinc/dub

Length of output: 82


🏁 Script executed:

git log --oneline packages/prisma/schema/schema.prisma | head -10

Repository: dubinc/dub

Length of output: 86


🏁 Script executed:

git show dfb134277^:packages/prisma/schema/schema.prisma 2>/dev/null | head -20

Repository: dubinc/dub

Length of output: 36


🏁 Script executed:

git show dfb134277 -- packages/prisma/schema/schema.prisma | head -60

Repository: dubinc/dub

Length of output: 2158


🏁 Script executed:

git log --all --diff-filter=D -- "**/schema.prisma" | head -20

Repository: dubinc/dub

Length of output: 365


🏁 Script executed:

git show dfb134277~1:packages/prisma/schema.prisma 2>&1 | head -20

Repository: dubinc/dub

Length of output: 95


🏁 Script executed:

git log --all --oneline -- "packages/prisma/**" | head -20

Repository: dubinc/dub

Length of output: 1131


🏁 Script executed:

git show d2284af7f | grep -A 20 "schema.prisma" | head -50

Repository: dubinc/dub

Length of output: 1439


🏁 Script executed:

git show d2284af7f:apps/web/prisma/schema/schema.prisma | grep -A 5 "generator client"

Repository: dubinc/dub

Length of output: 223


🏁 Script executed:

git show fef026a81:apps/web/prisma/schema/schema.prisma 2>&1 | grep -A 5 "generator client"

Repository: dubinc/dub

Length of output: 36


🏁 Script executed:

git log --all -p -- packages/prisma/schema/schema.prisma 2>&1 | grep -B 5 -A 5 "previewFeatures" | head -40

Repository: dubinc/dub

Length of output: 1103


🏁 Script executed:

git show dfb134277:packages/prisma/schema/schema.prisma | grep -A 3 "generator client"

Repository: dubinc/dub

Length of output: 107


Restore previewFeatures array — driverAdapters, prismaSchemaFolder, and omitApi remain preview features in Prisma 6.

The previewFeatures array was completely removed, but only fullTextIndex and fullTextSearch became generally available in Prisma 6. The features driverAdapters, prismaSchemaFolder, and omitApi remain preview features and must be re-enabled. Removing them will break functionality if the application depends on these features.

Update the generator block to:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["fullTextSearch", "fullTextIndex", "driverAdapters", "prismaSchemaFolder", "omitApi"]
}
🤖 Prompt for AI Agents
In packages/prisma/schema/schema.prisma around lines 7 to 9, the generator block
was stripped of the previewFeatures array which removed required preview flags;
restore the previewFeatures entry to re-enable driverAdapters,
prismaSchemaFolder, and omitApi (keep fullTextSearch and fullTextIndex too) by
adding previewFeatures =
["fullTextSearch","fullTextIndex","driverAdapters","prismaSchemaFolder","omitApi"]
inside the generator client block so Prisma 6 retains those preview features.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@coderabbitai are you absolutely sure? what is your source here?

Copy link
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

🌐 Web query:

Prisma 6 prismaSchemaFolder feature generally available or preview

💡 Result:

The prismaSchemaFolder feature is Generally Available (GA) — it was promoted out of Preview in Prisma v6.7.0. [1][2][3]

References:

  • Prisma blog / multi-file schema post noting GA in v6.7.0. [1]
  • Prisma changelog announcing prismaSchemaFolder moved to GA. [2]
  • Prisma docs / release notes (upgrade to v6) and related discussion/issues showing it was previously a Preview and had fixes around v6.6–6.7. [3]

🌐 Web query:

Prisma 6 omitApi feature generally available or preview status

💡 Result:

The omitApi (the client "omit" option) is generally available (GA) as of Prisma ORM 6.2.0 — you no longer need the preview flag. Earlier releases (5.13.0 → 6.1.x) required preview; a 6.2.1 patch fixed leftover preview checks. [1][2][3]

Sources:

  • Prisma docs — Excluding fields (notes that omit is GA in 6.2.0 and was preview in 5.16–6.1). [1]
  • Prisma 6.2.0 release notes / announcements (omit promoted to GA). [2]
  • 6.2.1 release note mentioning removal/fix of omitApi preview checks. [3]

🏁 Script executed:

#!/bin/bash
# Check if driverAdapters are actually being used in the codebase
rg -n "PrismaClient|prisma\." packages/prisma/ -A 3 -B 3 | head -100

Length of output: 1387


🌐 Web query:

Prisma 6.19 driverAdapters preview feature required for adapter

💡 Result:

Yes — to use driver adapters in Prisma v6 (including v6.19) you must opt in to the driverAdapters preview feature in your client generator. Add previewFeatures = ["driverAdapters"] (and run prisma generate) and install the adapter package (e.g. @prisma/adapter-neon, @prisma/adapter-planetscale, etc.). [1][2][3]

Example:
generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
}

Then install the adapter and run:
npm install @prisma/adapter-
npx prisma generate

References: Prisma 6.19 announcement, Serverless database drivers blog, and Preview-features docs. [1][2][3]


@steven-tey I apologize - I need to correct my previous comment. After verifying against the latest Prisma documentation, here's the accurate status of each feature:

Features that became GA (no longer need preview flags):

  • fullTextSearch and fullTextIndex - GA in Prisma 6.0
  • prismaSchemaFolder - GA in Prisma v6.7.0
  • omitApi - GA in Prisma v6.2.0

Feature that still requires preview flag:

  • driverAdapters - Still preview in Prisma 6.19

Looking at your codebase, packages/prisma/edge.ts uses the PlanetScale adapter:

const adapter = new PrismaPlanetScale(client);
export const prismaEdge = new PrismaClient({
  adapter,
});

This means you DO need to restore the preview feature, but only driverAdapters:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["driverAdapters"]
}

Sources:


🧠 Learnings used
Learnt from: TWilson023
Repo: dubinc/dub PR: 2935
File: packages/prisma/schema/workspace.prisma:21-36
Timestamp: 2025-10-06T15:48:45.956Z
Learning: In the Dub repository (dubinc/dub), Prisma schema changes are not managed with separate migration files. Do not flag missing Prisma migration files when schema changes are made to files like `packages/prisma/schema/workspace.prisma` or other schema files.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
apps/web/app/api/og/partner-rewind/route.tsx (3)

158-169: Replace any type with proper type or unknown for percentile fields.

The percentile fields are typed as any, which bypasses TypeScript's type checking. Since these are database Decimal values that will be converted to numbers, consider using a more specific type or at least unknown to maintain type safety until conversion.

🔎 Proposed type improvement
   type Row = {
     id: string;
     year: number;
     totalClicks: number;
     totalLeads: number;
     totalRevenue: number;
     totalEarnings: number;
-    clicksPercentile: any; // Decimal
-    leadsPercentile: any; // Decimal
-    revenuePercentile: any; // Decimal
-    earningsPercentile: any; // Decimal
+    clicksPercentile: string | number; // Decimal from database
+    leadsPercentile: string | number; // Decimal from database
+    revenuePercentile: string | number; // Decimal from database
+    earningsPercentile: string | number; // Decimal from database
   };

171-199: SQL query is properly parameterized.

The query correctly uses parameterized binding with ? placeholder (line 197) and passes rewindId as a parameter (line 198), preventing SQL injection vulnerabilities. The percentile calculations follow a consistent pattern.

Consider query performance optimization.

Each percentile calculation uses two subqueries (one for count comparison, one for total count). With four percentile fields, this results in 8 subqueries per request. If performance becomes an issue, consider computing percentiles in application code or using window functions if the database supports them.


201-211: Consider error handling for percentile conversions.

The Number() conversions (lines 207-210) could potentially return NaN if the database returns unexpected values. While the PartnerRewindSchema.parse() will validate the final result, the conversion assumes the percentile values are numeric. Consider adding validation or using a safer conversion approach if there's any uncertainty about the database return types.

🔎 Optional: Add defensive conversion
   return PartnerRewindSchema.parse({
     ...firstRow,
-    clicksPercentile: Number(firstRow.clicksPercentile),
-    leadsPercentile: Number(firstRow.leadsPercentile),
-    revenuePercentile: Number(firstRow.revenuePercentile),
-    earningsPercentile: Number(firstRow.earningsPercentile),
+    clicksPercentile: Number(firstRow.clicksPercentile) || 0,
+    leadsPercentile: Number(firstRow.leadsPercentile) || 0,
+    revenuePercentile: Number(firstRow.revenuePercentile) || 0,
+    earningsPercentile: Number(firstRow.earningsPercentile) || 0,
   });
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3eff145 and fb82909.

📒 Files selected for processing (1)
  • apps/web/app/api/og/partner-rewind/route.tsx
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: TWilson023
Repo: dubinc/dub PR: 2935
File: packages/prisma/schema/workspace.prisma:21-36
Timestamp: 2025-10-06T15:48:45.956Z
Learning: In the Dub repository (dubinc/dub), Prisma schema changes are not managed with separate migration files. Do not flag missing Prisma migration files when schema changes are made to files like `packages/prisma/schema/workspace.prisma` or other schema files.
🧬 Code graph analysis (1)
apps/web/app/api/og/partner-rewind/route.tsx (2)
packages/email/src/react-email.d.ts (1)
  • Row (9-9)
apps/web/lib/zod/schemas/partners.ts (1)
  • PartnerRewindSchema (345-356)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (3)
apps/web/app/api/og/partner-rewind/route.tsx (3)

18-25: Inconsistent AI summary regarding Satoshi Bold font.

The AI summary states "removed Satoshi-Bold font usage", but the code still loads Satoshi Bold (lines 18-24), includes it in the fonts array (lines 146-149), and uses it in the rendered component (line 123). The font loading appears correct; the summary is inaccurate.


111-111: The JPG medallion image is accessible and properly deployed.

The URL https://assets.dub.co/misc/partner-rewind-2025/top-medallion.jpg returns HTTP 200 with correct JPEG content type and appropriate file size (11.9 KB).


1-1: > Likely an incorrect or invalid review comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (4)
apps/web/app/api/og/partner-rewind/route.tsx (4)

159-170: Improve type safety for decimal fields.

Using any for percentile fields bypasses type checking. Consider using string or unknown and explicitly documenting that these are Decimal types from the database, or use a proper Decimal type if available.

🔎 Suggested type improvement
  type Row = {
    id: string;
    year: number;
    totalClicks: number;
    totalLeads: number;
    totalRevenue: number;
    totalEarnings: number;
-   clicksPercentile: any; // Decimal
-   leadsPercentile: any; // Decimal
-   revenuePercentile: any; // Decimal
-   earningsPercentile: any; // Decimal
+   clicksPercentile: string | number; // Decimal from DB
+   leadsPercentile: string | number; // Decimal from DB
+   revenuePercentile: string | number; // Decimal from DB
+   earningsPercentile: string | number; // Decimal from DB
  };

172-200: Consider SQL query performance impact.

The percentile calculation executes 8 subqueries (2 per percentile × 4 percentiles), each scanning the PartnerRewind table. For large datasets, this could be slow.

Consider:

  • Using SQL window functions (e.g., PERCENT_RANK()) for more efficient percentile calculation
  • Pre-computing percentiles during data ingestion if query performance becomes an issue
  • Adding database indexes on year and metric columns

However, if the current performance is acceptable for your dataset size, this can be deferred.

💡 Example using window functions (more efficient)
WITH percentiles AS (
  SELECT 
    id,
    year,
    totalClicks,
    totalLeads,
    totalRevenue,
    totalEarnings,
    PERCENT_RANK() OVER (PARTITION BY year ORDER BY totalClicks) as clicks_rank,
    PERCENT_RANK() OVER (PARTITION BY year ORDER BY totalLeads) as leads_rank,
    PERCENT_RANK() OVER (PARTITION BY year ORDER BY totalRevenue) as revenue_rank,
    PERCENT_RANK() OVER (PARTITION BY year ORDER BY totalEarnings) as earnings_rank
  FROM PartnerRewind
)
SELECT 
  id,
  year,
  totalClicks,
  totalLeads,
  totalRevenue,
  totalEarnings,
  ROUND(100 * clicks_rank) as clicksPercentile,
  ROUND(100 * leads_rank) as leadsPercentile,
  ROUND(100 * revenue_rank) as revenuePercentile,
  ROUND(100 * earnings_rank) as earningsPercentile
FROM percentiles
WHERE id = ?

Note: Verify PlanetScale supports window functions before implementing.


208-211: Document decimal precision handling.

Converting database decimals to JavaScript numbers using Number() may lose precision for very large values. For percentiles (0-100 range), this is safe. However, consider documenting this assumption or validating the range.


156-157: Document the reasoning for PlanetScale migration.

The comment mentions this approach was chosen because "couldn't get that to work with dynamic client + conditional Prisma.sql." Consider documenting in the PR description or code comments why PlanetScale was chosen over Prisma v6, especially if Prisma v6 should theoretically support this use case.

This helps future maintainers understand if this is a temporary workaround or a permanent architectural decision.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb82909 and 88f5517.

📒 Files selected for processing (1)
  • apps/web/app/api/og/partner-rewind/route.tsx
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: TWilson023
Repo: dubinc/dub PR: 2935
File: packages/prisma/schema/workspace.prisma:21-36
Timestamp: 2025-10-06T15:48:45.956Z
Learning: In the Dub repository (dubinc/dub), Prisma schema changes are not managed with separate migration files. Do not flag missing Prisma migration files when schema changes are made to files like `packages/prisma/schema/workspace.prisma` or other schema files.
🧬 Code graph analysis (1)
apps/web/app/api/og/partner-rewind/route.tsx (2)
apps/web/app/(ee)/api/partner-profile/rewind/route.ts (1)
  • GET (7-19)
apps/web/lib/zod/schemas/partners.ts (1)
  • PartnerRewindSchema (345-356)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (1)
apps/web/app/api/og/partner-rewind/route.tsx (1)

112-112: No action needed. The JPG asset exists and is properly accessible (HTTP 200), and JPG is an appropriate format for a 6×6 pixel medal badge where transparency is not a concern.

@steven-tey
Copy link
Collaborator

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

✅ Actions performed

Full review triggered.

@steven-tey steven-tey merged commit a2dfaa9 into main Dec 23, 2025
7 of 8 checks passed
@steven-tey steven-tey deleted the upgrade-prisma branch December 23, 2025 21:35
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