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

Skip to content

Conversation

@devkiran
Copy link
Collaborator

@devkiran devkiran commented Dec 18, 2025

Summary by CodeRabbit

Release Notes

  • New Features
    • Bounty submissions now undergo automatic workflow condition evaluation, with submissions automatically marked as completed when conditions are met.
    • Performance count metrics are now tracked and included in submission records for enhanced monitoring and visibility.

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

@vercel
Copy link
Contributor

vercel bot commented Dec 18, 2025

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

Project Deployment Review Updated (UTC)
dub Ready Ready Preview Dec 18, 2025 4:41pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 18, 2025

Walkthrough

The cron handler for creating draft bounty submissions now evaluates workflow conditions based on partner performance counts. When a condition is satisfied, submissions are pre-submitted with status and timestamp populated automatically. Type safety and imports for condition evaluation were added.

Changes

Cohort / File(s) Summary
Bounty submission workflow condition evaluation
apps/web/app/(ee)/api/cron/bounties/create-draft-submissions/route.ts
Added evaluateWorkflowCondition logic to determine submission status based on performance count; pre-submits records when conditions are met; introduced strongly-typed bountySubmissionsToCreate array; added imports for evaluateWorkflowCondition and Prisma types

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify evaluateWorkflowCondition implementation and its interaction with performance count
  • Confirm the logic for pre-submission (status and completedAt timestamp) is correct
  • Review type safety of the bountySubmissionsToCreate array structure
  • Check that the optional submission metadata fields are properly handled

Possibly related PRs

Suggested reviewers

  • steven-tey

Poem

🐰 A draft blooms when conditions align,
Performance counted, workflows divine,
Submissions pre-born with timestamps so fine,
One file transformed, types now crystalline!
hop hop ✨

Pre-merge checks and finishing touches

βœ… Passed checks (3 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title accurately describes the main change: auto-submission of performance bounties when performance thresholds are met at creation time, which aligns with the code changes that evaluate workflow conditions and set submission status accordingly.
Docstring Coverage βœ… Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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-performance-bounties

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.

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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/web/app/(ee)/api/cron/bounties/create-draft-submissions/route.ts (1)

135-137: Add defensive check for empty triggerConditions array.

While performance bounties always have at least one trigger condition during normal operation (by creation and schema validation), the code accesses [0] without a guardβ€”inconsistent with safe patterns used elsewhere (e.g., get-bounty-with-details.ts). In a cron job, any failure cascades. Consider adding:

if (!condition) {
  return logAndRespond(
    `Bounty ${bountyId} workflow has no trigger conditions.`
  );
}

after line 137.

πŸ“œ Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 022bd9a and ab1b7c0.

πŸ“’ Files selected for processing (1)
  • apps/web/app/(ee)/api/cron/bounties/create-draft-submissions/route.ts (3 hunks)
🧰 Additional context used
🧠 Learnings (5)
πŸ““ Common learnings
Learnt from: TWilson023
Repo: dubinc/dub PR: 2736
File: apps/web/lib/actions/partners/create-bounty-submission.ts:105-112
Timestamp: 2025-08-26T14:32:33.851Z
Learning: Non-performance bounties are required to have submissionRequirements. In create-bounty-submission.ts, it's appropriate to let the parsing fail if submissionRequirements is null for non-performance bounties, as this indicates a data integrity issue that should be caught.
Learnt from: devkiran
Repo: dubinc/dub PR: 2736
File: apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-info.tsx:45-56
Timestamp: 2025-08-25T17:39:38.965Z
Learning: In the bounty system, each partner can only submit to the same bounty once. This means totalSubmissions (pending + approved + rejected) equals the number of unique partners who have submitted, making UI text like "X of Y partners completed" accurate when using totalSubmissions.
πŸ“š Learning: 2025-08-26T14:32:33.851Z
Learnt from: TWilson023
Repo: dubinc/dub PR: 2736
File: apps/web/lib/actions/partners/create-bounty-submission.ts:105-112
Timestamp: 2025-08-26T14:32:33.851Z
Learning: Non-performance bounties are required to have submissionRequirements. In create-bounty-submission.ts, it's appropriate to let the parsing fail if submissionRequirements is null for non-performance bounties, as this indicates a data integrity issue that should be caught.

Applied to files:

  • apps/web/app/(ee)/api/cron/bounties/create-draft-submissions/route.ts
πŸ“š Learning: 2025-09-12T17:31:10.548Z
Learnt from: devkiran
Repo: dubinc/dub PR: 2833
File: apps/web/lib/actions/partners/approve-bounty-submission.ts:53-61
Timestamp: 2025-09-12T17:31:10.548Z
Learning: In approve-bounty-submission.ts, the logic `bounty.rewardAmount ?? rewardAmount` is intentional. Bounties with preset reward amounts should use those fixed amounts, and the rewardAmount override parameter is only used when bounty.rewardAmount is null/undefined (for custom reward bounties). This follows the design pattern where bounties are either "flat rate" (fixed amount) or "custom" (variable amount set during approval).

Applied to files:

  • apps/web/app/(ee)/api/cron/bounties/create-draft-submissions/route.ts
πŸ“š Learning: 2025-08-25T17:39:38.965Z
Learnt from: devkiran
Repo: dubinc/dub PR: 2736
File: apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-info.tsx:45-56
Timestamp: 2025-08-25T17:39:38.965Z
Learning: In the bounty system, each partner can only submit to the same bounty once. This means totalSubmissions (pending + approved + rejected) equals the number of unique partners who have submitted, making UI text like "X of Y partners completed" accurate when using totalSubmissions.

Applied to files:

  • apps/web/app/(ee)/api/cron/bounties/create-draft-submissions/route.ts
πŸ“š Learning: 2025-12-15T16:45:51.667Z
Learnt from: devkiran
Repo: dubinc/dub PR: 3213
File: apps/web/app/(ee)/api/cron/auto-approve-partner/route.ts:122-122
Timestamp: 2025-12-15T16:45:51.667Z
Learning: In cron endpoints under apps/web/app/(ee)/api/cron, continue using handleCronErrorResponse for error handling. Do not detect QStash callbacks or set Upstash-NonRetryable-Error headers in these cron routes, so QStash can retry cron errors via its native retry mechanism. The existing queueFailedRequestForRetry logic should remain limited to specific user-facing API endpoints (e.g., /api/track/lead, /api/track/sale, /api/links) to retry only transient Prisma/database errors. This pattern should apply to all cron endpoints under the cron directory in this codebase.

Applied to files:

  • apps/web/app/(ee)/api/cron/bounties/create-draft-submissions/route.ts
⏰ 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 (2)
apps/web/app/(ee)/api/cron/bounties/create-draft-submissions/route.ts (2)

3-3: LGTM! Required imports for new functionality.

The imports support the new workflow condition evaluation and type-safe submission creation logic.

Also applies to: 9-9


155-172: Approve the auto-submission logic!

The conditional auto-submission feature is well-implemented:

  • Correctly evaluates the workflow condition using the partner's performance count
  • Auto-submits by setting status: "submitted" and completedAt when the threshold is met
  • Stores performanceCount for audit trail

This achieves the PR objective of automatically submitting performance bounties when thresholds are reached at creation time.

@steven-tey steven-tey merged commit a8f7288 into main Dec 18, 2025
8 of 9 checks passed
@steven-tey steven-tey deleted the fix-performance-bounties branch December 18, 2025 16:57
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