Skip to content

FEAT: Dynamic bounty start date#4187

Open
devkiran wants to merge 33 commits into
mainfrom
dynamic-bounty-start-date
Open

FEAT: Dynamic bounty start date#4187
devkiran wants to merge 33 commits into
mainfrom
dynamic-bounty-start-date

Conversation

@devkiran

@devkiran devkiran commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Relative bounties: start after a partner joins and end after a chosen duration (preset or custom).
    • Updated bounty timing editor and consistent duration labels across dashboard, embeds, and Slack; webhook payloads now include timing fields.
    • Referral embed submissions now post to the bounty-specific submissions endpoint.
  • Bug Fixes
    • Partner eligibility/visibility now correctly uses effective start/end periods; social-metrics sync and partner notifications follow the new timing rules.
    • Clearing partner groups on bounty updates now behaves as expected.
  • Tests
    • Added E2E coverage for relative start/end combinations and updated webhook schema validation.

@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
dub Ready Ready Preview Jul 24, 2026 11:22pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds absolute and enrollment-relative bounty timing, centralizes partner eligibility and effective-period calculations, and updates bounty APIs, cron workflows, submission flows, dashboard/embed interfaces, Slack output, webhooks, and tests.

Changes

Bounty timing and eligibility

Layer / File(s) Summary
Timing contracts and eligibility primitives
apps/web/prisma/schema/bounty.prisma, apps/web/lib/bounty/*, apps/web/lib/zod/schemas/*
Adds absolute/relative timing fields, effective-period helpers, centralized eligibility checks, and updated schemas.
Bounty API timing and visibility
apps/web/app/(ee)/api/bounties/..., apps/web/app/(ee)/api/embed/..., apps/web/app/(ee)/api/partner-profile/..., apps/web/lib/bounty/api/get-bounties-for-partner.ts
Persists timing modes, computes partner-specific periods, centralizes access checks, supports route-based embed submissions, and narrows relation queries.
Submissions, workflows, and cron processing
apps/web/lib/bounty/api/create-bounty-submission.ts, apps/web/lib/api/workflows/*, apps/web/app/(ee)/api/cron/bounties/*
Applies effective periods and eligibility to submissions, workflow completion, draft creation, notifications, and social-metric synchronization.
Timing editor and bounty presentation
apps/web/app/app.dub.co/(dashboard)/.../bounty-duration.tsx, use-add-edit-bounty-form.ts, bounty-card.tsx, apps/web/lib/integrations/slack/transform.ts
Adds preset/custom duration editing and centralized timing labels across dashboard, embed, card, and Slack displays.
Validation and coverage
apps/web/tests/*, apps/web/lib/webhook/sample-events/*, apps/web/lib/actions/partners/*
Updates timestamp writes, webhook samples, nullable timing handling, and relative timing tests.

Estimated code review effort: 5 (Critical) | ~90 minutes

Possibly related PRs

Suggested reviewers: pepeladeira, steven-tey

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.30% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main change: supporting dynamic bounty start timing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dynamic-bounty-start-date

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.

@devkiran
devkiran marked this pull request as ready for review July 21, 2026 12:55

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

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/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/add-edit-bounty-sheet.tsx (1)

283-303: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Submission window ignores endsAfterDays end dates. The gating and validation here only look at endsAt, so bounties that end via endsAfterDays stay disabled and hit the “An end date is required…” path even though they have an effective end date. If those bounties should support submission windows, use the resolved end date here instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/web/app/app.dub.co/`(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/add-edit-bounty-sheet.tsx
around lines 283 - 303, Update the submission-window gating and validation
around the Switch and its tooltip to use the resolved effective end date,
including bounties configured with endsAfterDays, instead of checking endsAt
directly. Preserve the existing allowedSubmissions > 1 restriction and ensure
valid resolved end dates do not trigger the “end date required” state.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/web/app/`(ee)/api/bounties/route.ts:
- Around line 114-141: The partner-scoped branch in the bounty mapping flow must
use the shared visibility rules instead of only checking startsAt and endsAt.
Update the logic around getEffectiveBountyPeriod and isPartnerEligibleForBounty
to exclude archived bounties and enforce the relative-bounty partnerJoinedAt
versus bounty.createdAt rule, while preserving the existing time-window
filtering and output mapping.

In
`@apps/web/app/app.dub.co/`(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx:
- Around line 73-106: Replace every font-regular utility with font-normal in the
bounty card rows around BountyRewardDescription, dateRangeLabel,
partnerAudienceLabel, and eligible group rendering. Apply the same change to the
partner-audience row in confirm-create-bounty-modal.tsx; update both affected
files at the specified sites.

In `@apps/web/lib/types.ts`:
- Around line 868-876: Keep programEnrollment optional in WorkflowContext so
executeWorkflows callers providing only trigger and identity remain valid.
Update the WorkflowContext declaration around programEnrollment without making
the resolved enrollment data required at the caller boundary.

---

Outside diff comments:
In
`@apps/web/app/app.dub.co/`(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/add-edit-bounty-sheet.tsx:
- Around line 283-303: Update the submission-window gating and validation around
the Switch and its tooltip to use the resolved effective end date, including
bounties configured with endsAfterDays, instead of checking endsAt directly.
Preserve the existing allowedSubmissions > 1 restriction and ensure valid
resolved end dates do not trigger the “end date required” state.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ba58c53e-7f82-467a-bbea-437d7f136abe

📥 Commits

Reviewing files that changed from the base of the PR and between 6de9e52 and 31c2f3b.

📒 Files selected for processing (56)
  • apps/web/app/(ee)/api/bounties/[bountyId]/route.ts
  • apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts
  • apps/web/app/(ee)/api/bounties/[bountyId]/sync-social-metrics/route.ts
  • apps/web/app/(ee)/api/bounties/route.ts
  • apps/web/app/(ee)/api/cron/bounties/create-draft-submissions/route.ts
  • apps/web/app/(ee)/api/cron/bounties/notify-partners/route.ts
  • apps/web/app/(ee)/api/cron/bounties/queue-sync-social-metrics/route.ts
  • apps/web/app/(ee)/api/cron/bounties/sync-social-metrics/route.ts
  • apps/web/app/(ee)/api/embed/referrals/bounties/[bountyId]/social-content-stats/route.ts
  • apps/web/app/(ee)/api/embed/referrals/bounties/[bountyId]/submissions/route.ts
  • apps/web/app/(ee)/api/partner-profile/programs/[programId]/bounties/[bountyId]/route.ts
  • apps/web/app/(ee)/api/partner-profile/programs/[programId]/bounties/[bountyId]/social-content-stats/route.ts
  • apps/web/app/(ee)/api/partner-profile/programs/[programId]/bounties/route.ts
  • apps/web/app/(ee)/app.dub.co/embed/referrals/bounties/submission-fields.tsx
  • apps/web/app/(ee)/app.dub.co/embed/referrals/bounties/submission-form.tsx
  • apps/web/app/(ee)/app.dub.co/embed/referrals/get-referrals-embed-data.ts
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-info.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/add-edit-bounty-sheet.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/bounty-criteria.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/bounty-duration.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/confirm-create-bounty-modal.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/use-add-edit-bounty-form.ts
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-move-rules.tsx
  • apps/web/lib/actions/partners/accept-program-invite.ts
  • apps/web/lib/actions/partners/bulk-approve-partners.ts
  • apps/web/lib/api/groups/move-partners-to-group.ts
  • apps/web/lib/api/partners/applications/approve-partner.ts
  • apps/web/lib/api/partners/create-and-enroll-partner.ts
  • apps/web/lib/api/workflows/execute-complete-bounty-workflow.ts
  • apps/web/lib/api/workflows/execute-workflows.ts
  • apps/web/lib/bounty/api/bounty-availability.ts
  • apps/web/lib/bounty/api/create-bounty-submission.ts
  • apps/web/lib/bounty/api/get-bounties-for-partner.ts
  • apps/web/lib/bounty/api/get-bounty-submission-upload-url.ts
  • apps/web/lib/bounty/api/get-bounty-with-details.ts
  • apps/web/lib/bounty/api/get-group-bounty-summaries.ts
  • apps/web/lib/bounty/api/trigger-draft-bounty-submissions.ts
  • apps/web/lib/bounty/api/validate-bounty.ts
  • apps/web/lib/bounty/bounty-period.ts
  • apps/web/lib/firstpromoter/import-partners.ts
  • apps/web/lib/integrations/slack/transform.ts
  • apps/web/lib/partnerstack/import-partners.ts
  • apps/web/lib/rewardful/import-partners.ts
  • apps/web/lib/tapfiliate/import-partners.ts
  • apps/web/lib/tolt/import-partners.ts
  • apps/web/lib/types.ts
  • apps/web/lib/webhook/sample-events/bounty-created.json
  • apps/web/lib/webhook/sample-events/bounty-updated.json
  • apps/web/lib/zod/schemas/bounties.ts
  • apps/web/lib/zod/schemas/partner-profile.ts
  • apps/web/prisma/schema/bounty.prisma
  • apps/web/prisma/schema/program.prisma
  • apps/web/scripts/migrations/backfill-group-joined-at.ts
  • apps/web/tests/bounties/index.test.ts
  • apps/web/tests/webhooks/index.test.ts
💤 Files with no reviewable changes (1)
  • apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts

Comment thread apps/web/app/(ee)/api/bounties/route.ts
Comment thread apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx Outdated
Comment thread apps/web/lib/types.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/web/tests/bounties/index.test.ts`:
- Around line 624-638: Move the onTestFinished cleanup registration to
immediately after the successful bounty creation POST, before the PATCH request
and assertions; keep it targeting the created bounty’s id so cleanup runs even
when later test steps fail.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9483f6a8-0918-4c4d-8b93-f3d489d98c3b

📥 Commits

Reviewing files that changed from the base of the PR and between 39ea833 and e50d417.

📒 Files selected for processing (1)
  • apps/web/tests/bounties/index.test.ts

Comment on lines +624 to +638
const { status: patchStatus, data: updated } = await http.patch<Bounty>({
path: `/bounties/${bounty.id}`,
body: { endsAfterDays: 180 },
});

expect(patchStatus).toEqual(200);
expect(updated).toMatchObject({
startMode: BountyStartMode.relative,
startsAt: null,
endsAfterDays: 180,
});

onTestFinished(async () => {
await h.deleteBounty(bounty.id);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Register cleanup immediately after creation.

If the PATCH call or either assertion fails, onTestFinished is never registered and the created bounty remains in the E2E environment. Register it directly after the successful POST.

Proposed fix
     expect(bounty).toMatchObject({
       startMode: BountyStartMode.relative,
       startsAt: null,
       endsAt: null,
       endsAfterDays: 30,
     });
 
+    onTestFinished(async () => {
+      await h.deleteBounty(bounty.id);
+    });
+
     const { status: patchStatus, data: updated } = await http.patch<Bounty>({
       path: `/bounties/${bounty.id}`,
       body: { endsAfterDays: 180 },
     });
-
-    onTestFinished(async () => {
-      await h.deleteBounty(bounty.id);
-    });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { status: patchStatus, data: updated } = await http.patch<Bounty>({
path: `/bounties/${bounty.id}`,
body: { endsAfterDays: 180 },
});
expect(patchStatus).toEqual(200);
expect(updated).toMatchObject({
startMode: BountyStartMode.relative,
startsAt: null,
endsAfterDays: 180,
});
onTestFinished(async () => {
await h.deleteBounty(bounty.id);
});
const { status: patchStatus, data: updated } = await http.patch<Bounty>({
path: `/bounties/${bounty.id}`,
body: { endsAfterDays: 180 },
});
expect(patchStatus).toEqual(200);
expect(updated).toMatchObject({
startMode: BountyStartMode.relative,
startsAt: null,
endsAfterDays: 180,
});
onTestFinished(async () => {
await h.deleteBounty(bounty.id);
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/tests/bounties/index.test.ts` around lines 624 - 638, Move the
onTestFinished cleanup registration to immediately after the successful bounty
creation POST, before the PATCH request and assertions; keep it targeting the
created bounty’s id so cleanup runs even when later test steps fail.

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.

2 participants