-
Notifications
You must be signed in to change notification settings - Fork 34
feat: cohort entitlements #469
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
WalkthroughThe updates introduce entitlement assignment for cohort content access after cohort purchases, set a default value for the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Workflow
participant DB
User->>Workflow: Purchase cohort product
Workflow->>DB: Retrieve organization membership
alt Membership found
Workflow->>DB: Assign entitlements for each cohort resource
DB-->>Workflow: Entitlement records inserted
end
Workflow-->>User: Access granted to cohort resources
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 0
🧹 Nitpick comments (2)
packages/commerce-next/src/pricing/pricing.tsx (1)
664-664
: Enhanced conditional rendering of LiveQuantityThe component now only renders when both conditions are true: the event is live AND there are quantities available. This prevents showing "spots left" indicators when there's nothing available.
You might consider adding a comment explaining why both conditions are required for added clarity in the future.
apps/ai-hero/src/inngest/functions/post-cohort-purchase-workflow.ts (1)
103-121
: Implemented cohort entitlement assignmentThis new feature assigns entitlements to users after a cohort purchase, giving them access to the cohort's resources. The implementation correctly:
- Checks for prerequisites before processing
- Creates entitlement records for each resource in the cohort
- Associates the records with the proper user, organization, and membership
- Includes resource IDs in metadata for traceability
Consider adding error handling within the loop to prevent a single resource failure from stopping the entire entitlement process.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/ai-hero/src/inngest/functions/post-cohort-purchase-workflow.ts
(2 hunks)apps/ai-hero/src/lib/cohort.ts
(1 hunks)packages/adapter-drizzle/src/lib/mysql/index.ts
(1 hunks)packages/commerce-next/src/pricing/pricing.tsx
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/ai-hero/src/lib/cohort.ts (1)
packages/core/src/schemas/product-schema.ts (1)
productSchema
(9-41)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: typecheck
- GitHub Check: build
- GitHub Check: format
- GitHub Check: lint
- GitHub Check: e2e-node (course-builder-web)
🔇 Additional comments (3)
apps/ai-hero/src/lib/cohort.ts (1)
17-25
: Good defensive programming with default empty arrayAdding a default empty array for
resourceProducts
is a good practice that prevents potential null/undefined errors when iterating over this field in other parts of the codebase.This change works well with the new entitlement assignment logic in the post-cohort-purchase workflow.
packages/adapter-drizzle/src/lib/mysql/index.ts (1)
740-743
: Enhanced query to include related entitiesIncluding organization and user data in the membership query result provides more complete data to downstream code, potentially reducing the need for additional database queries.
This enriched data is particularly valuable for the cohort entitlement assignment workflow where organization and user details are needed.
apps/ai-hero/src/inngest/functions/post-cohort-purchase-workflow.ts (1)
2-6
: Updated imports to support entitlement functionalityThe additional imports for
entitlements
andentitlementTypes
are necessary for the new entitlement assignment logic.
https://www.loom.com/share/eee2bb6ef2fb42bb9825b550b2bdd78e
Summary by CodeRabbit
New Features
Improvements