-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix Rewardful import #2982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Rewardful import #2982
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
💡 Enable Vercel Agent with $100 free credit for automated AI reviews |
WalkthroughThe pull request modifies the Rewardful import flow to enhance affiliate coupon processing and link creation. Changes include filtering coupons by partner existence, adding partner validation, reversing the link creation condition to prevent duplicates, and attaching descriptive comments to generated links. Changes
Sequence Diagram(s)sequenceDiagram
participant ImportFlow
participant CouplonFilter as Coupon Filter
participant PartnerCheck as Partner Validation
participant LinkCreation as Link Creation
participant BulkOps as Bulk Operations
rect rgb(200, 220, 255)
note right of ImportFlow: OLD: Unconditional link creation
ImportFlow->>LinkCreation: Create links
LinkCreation->>BulkOps: bulkCreateLinks (always)
end
rect rgb(200, 255, 220)
note right of ImportFlow: NEW: Conditional creation with filtering
ImportFlow->>CouplonFilter: Filter coupons by partner
CouplonFilter->>PartnerCheck: Validate partner exists in Dub
PartnerCheck->>LinkCreation: Only if links empty
LinkCreation->>BulkOps: bulkCreateLinks (if links to create)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes The changes involve logic modifications across two related files with new filtering conditions and type usage (ProcessedLinkProps), but the scope is contained to the Rewardful import flow. The filtering logic and reversed condition require careful verification against existing behavior, but the changes follow consistent patterns. Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/web/lib/rewardful/import-affiliate-coupons.ts
(3 hunks)apps/web/lib/rewardful/import-partners.ts
(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-06T07:59:03.120Z
Learnt from: devkiran
PR: dubinc/dub#2177
File: apps/web/lib/api/links/bulk-create-links.ts:66-84
Timestamp: 2025-06-06T07:59:03.120Z
Learning: In apps/web/lib/api/links/bulk-create-links.ts, the team accepts the risk of potential undefined results from links.find() operations when building invalidLinks arrays, because existing links are fetched from the database based on the input links, so matches are expected to always exist.
Applied to files:
apps/web/lib/rewardful/import-partners.ts
apps/web/lib/rewardful/import-affiliate-coupons.ts
🧬 Code graph analysis (2)
apps/web/lib/rewardful/import-partners.ts (1)
apps/web/lib/api/links/bulk-create-links.ts (1)
bulkCreateLinks
(18-236)
apps/web/lib/rewardful/import-affiliate-coupons.ts (2)
apps/web/lib/types.ts (1)
ProcessedLinkProps
(313-318)apps/web/lib/api/links/bulk-create-links.ts (1)
bulkCreateLinks
(18-236)
⏰ 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 (4)
apps/web/lib/rewardful/import-affiliate-coupons.ts (4)
58-74
: Good improvement: filtering coupons by partner existence.This change ensures that links are only created for coupons where the corresponding partner exists in Dub, preventing orphaned links and potential errors downstream.
84-86
: Defensive check is technically unnecessary but adds safety.The
partnerId
check is defensive programming sincefilteredCoupons
(line 59) already filters by partners that exist infilteredPartners
. However, this guard protects against potential future changes and makes the code more resilient.
99-99
: Good addition: descriptive comments for tracking.Adding the
comments
field with the coupon token provides useful context for each generated link, making it easier to trace back to the original Rewardful coupon.
105-109
: Good practice: guard clause for bulk operations.Wrapping the
bulkCreateLinks
call in a length check prevents unnecessary function calls when there are no links to create, improving efficiency and aligning with the pattern used inbulkCreateLinks
itself (which also returns early if links.length === 0).
Summary by CodeRabbit
Release Notes
Bug Fixes
Improvements