Skip to content

Stop duplicating dates when duplicating questions#4502

Draft
SylvainChevalier wants to merge 1 commit intomainfrom
claude/issue-4456-stop-duplicating-dates-when-duplicating
Draft

Stop duplicating dates when duplicating questions#4502
SylvainChevalier wants to merge 1 commit intomainfrom
claude/issue-4456-stop-duplicating-dates-when-duplicating

Conversation

@SylvainChevalier
Copy link
Contributor

@SylvainChevalier SylvainChevalier commented Mar 17, 2026

Fixes #4456

When duplicating a question, skip copying scheduling date fields (open_time, scheduled_close_time, scheduled_resolve_time, cp_reveal_time, published_at) so they start empty. Bounds and zero point for date range questions are still duplicated.

Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • When creating new questions or groups by duplicating existing ones, all scheduling and timing fields (open times, close times, resolve times, and reveal times) are now reset to empty, allowing you to specify new times for your duplicates without having to manually clear values inherited from the original.

When duplicating a question (mode='create' with existing post), skip copying
scheduling date fields (open_time, scheduled_close_time, scheduled_resolve_time,
cp_reveal_time, published_at) so they start empty. Bounds (range_min, range_max)
and zero_point for date range questions are still duplicated as before.

Fixes #4456

Co-authored-by: Sylvain <SylvainChevalier@users.noreply.github.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2026

📝 Walkthrough

Walkthrough

Changes to form component initialization logic introduce an isDuplicate flag (mode === "create" && !!post) to detect question duplication operations. When duplicating, time-related fields (scheduled_close_time, scheduled_resolve_time, open_time, cp_reveal_time) are reset to undefined instead of copying from the source post.

Changes

Cohort / File(s) Summary
Question/Group Form Components
front_end/src/app/(main)/questions/components/question_form.tsx, front_end/src/app/(main)/questions/components/group_form.tsx
Introduced isDuplicate detection flag and conditional date/time field initialization. When duplicating questions, time-related fields are set to undefined in form defaultValues and DateInput props instead of copying from the source post.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • elisescu
  • lsabor
  • hlbmtc
  • cemreinanc

Poem

🐰 Hop, hop, hooray! A clever fix so neat,
When copying questions, the dates now retreat,
Fresh times for new questions, the boundaries stay true,
Duplicates now dazzle with a temporal debut! ✨

🚥 Pre-merge checks | ✅ 4
✅ 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 'Stop duplicating dates when duplicating questions' clearly and concisely summarizes the main change: preventing date fields from being copied when a question is duplicated.
Linked Issues check ✅ Passed The PR successfully implements the requirements from issue #4456: skips copying scheduling dates (open_time, scheduled_close_time, scheduled_resolve_time, cp_reveal_time, published_at) while preserving range metadata (range_min, range_max, zero_point) for date-range questions.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the stated objective of preventing date field duplication when duplicating questions, with no unrelated modifications introduced.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/issue-4456-stop-duplicating-dates-when-duplicating
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@github-actions
Copy link
Contributor

🚀 Preview Environment

Your preview environment is ready!

Resource Details
🌐 Preview URL https://metaculus-pr-4502-claude-issue-4456-stop-duplica-preview.mtcl.cc
📦 Docker Image ghcr.io/metaculus/metaculus:claude-issue-4456-stop-duplicating-dates-when-duplicating-e967146
🗄️ PostgreSQL NeonDB branch preview/pr-4502-claude-issue-4456-stop-duplica
Redis Fly Redis mtc-redis-pr-4502-claude-issue-4456-stop-duplica

Details

  • Commit: c7a9306d7b6f0337b50d4326848a48f3a6cf289d
  • Branch: claude/issue-4456-stop-duplicating-dates-when-duplicating
  • Fly App: metaculus-pr-4502-claude-issue-4456-stop-duplica

ℹ️ Preview Environment Info

Isolation:

  • PostgreSQL and Redis are fully isolated from production
  • Each PR gets its own database branch and Redis instance
  • Changes pushed to this PR will trigger a new deployment

Limitations:

  • Background workers and cron jobs are not deployed in preview environments
  • If you need to test background jobs, use Heroku staging environments

Cleanup:

  • This preview will be automatically destroyed when the PR is closed

@SylvainChevalier
Copy link
Contributor Author

lgtm.

@SylvainChevalier SylvainChevalier marked this pull request as ready for review March 19, 2026 16:25
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.

Caution

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

⚠️ Outside diff range comments (1)
front_end/src/app/(main)/questions/components/question_form.tsx (1)

974-980: ⚠️ Potential issue | 🟡 Minor

Missing isDuplicate check for published_at DateInput.

Per the PR objective, published_at should also be cleared during duplication. While the form's defaultValues (line 474) sets it to undefined, this DateInput component's defaultValue prop is inconsistent with the other date fields (lines 877, 890, 906, 919) that all use the isDuplicate conditional.

🔧 Proposed fix for consistency
             <DateInput
               control={form.control as unknown as Control<FieldValues>}
               name="published_at"
-              defaultValue={post?.published_at}
+              defaultValue={isDuplicate ? undefined : post?.published_at}
               errors={form.formState.errors.published_at}
               className="w-full rounded border border-gray-500 px-3 py-2 text-base dark:border-gray-500-dark dark:bg-blue-50-dark"
             />
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@front_end/src/app/`(main)/questions/components/question_form.tsx around lines
974 - 980, The DateInput for published_at is missing the isDuplicate check,
causing duplication to retain the original date; update the DateInput
(name="published_at", component DateInput using form.control and
form.formState.errors) to set its defaultValue the same way as the other date
fields—i.e. use the isDuplicate conditional so defaultValue is undefined when
isDuplicate is true (instead of always using post?.published_at) to match the
form's defaultValues behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@front_end/src/app/`(main)/questions/components/question_form.tsx:
- Around line 974-980: The DateInput for published_at is missing the isDuplicate
check, causing duplication to retain the original date; update the DateInput
(name="published_at", component DateInput using form.control and
form.formState.errors) to set its defaultValue the same way as the other date
fields—i.e. use the isDuplicate conditional so defaultValue is undefined when
isDuplicate is true (instead of always using post?.published_at) to match the
form's defaultValues behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2d6a2a73-bdf8-4722-8219-588d0992b52d

📥 Commits

Reviewing files that changed from the base of the PR and between 8c53a55 and e967146.

📒 Files selected for processing (2)
  • front_end/src/app/(main)/questions/components/group_form.tsx
  • front_end/src/app/(main)/questions/components/question_form.tsx

@SylvainChevalier SylvainChevalier marked this pull request as draft March 20, 2026 10:38
@SylvainChevalier
Copy link
Contributor Author

oops I put the wrong PR up for review.

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.

Stop duplicating dates when duplicating questions

1 participant