Skip to content

Fire tournament notifications when posts are published#4745

Draft
SylvainChevalier wants to merge 2 commits into
mainfrom
claude/issue-4701-change-tournament-notifications-so-that
Draft

Fire tournament notifications when posts are published#4745
SylvainChevalier wants to merge 2 commits into
mainfrom
claude/issue-4701-change-tournament-notifications-so-that

Conversation

@SylvainChevalier
Copy link
Copy Markdown
Contributor

Closes #4701

Tournament / project follower notifications previously fired when a question's open_time passed. With pre-predictions, questions are surfaced to users before forecasting opens (status = Upcoming), so the notification should fire at publish time instead.

  • Add Question.published_at_triggered to gate publish-time notifications
  • job_check_post_open_event now fires notify_project_subscriptions_post_open once when the parent Post.published_at passes
  • Remove tournament notification from handle_question_open (the post-level OPEN status change still fires at open_time)
  • notify_post_added_to_project now uses the new flag
  • Data migration back-marks already-published questions to avoid mass back-fire on deploy

Generated with Claude Code

Tournament / project follower notifications previously fired when a
question's open_time passed. With pre-predictions, questions are surfaced
to users before forecasting opens (status = Upcoming), so notifications
should fire at publish time instead.

- Add `Question.published_at_triggered` to gate publish-time notifications
- Cron job now fires `notify_project_subscriptions_post_open` once when
  the parent Post's `published_at` passes
- Remove tournament notification from `handle_question_open` (still fires
  the post-level OPEN status change at open_time)
- `notify_post_added_to_project` now uses the new flag

Refs #4701

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

coderabbitai Bot commented May 19, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d0996cd4-f8da-43d7-9c8e-6bee46177bc5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/issue-4701-change-tournament-notifications-so-that

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
Copy Markdown
Contributor

github-actions Bot commented May 19, 2026

🚀 Preview Environment

Your preview environment is ready!

Resource Details
🌐 Preview URL https://metaculus-pr-4745-claude-issue-4701-change-tourn-preview.mtcl.cc
📦 Docker Image ghcr.io/metaculus/metaculus:claude-issue-4701-change-tournament-notifications-so-that-d14f79f
🗄️ PostgreSQL NeonDB branch preview/pr-4745-claude-issue-4701-change-tourn
Redis Fly Redis mtc-redis-pr-4745-claude-issue-4701-change-tourn

Details

  • Commit: 56644ffd4aa9b7cbf08c3c4de1194e3363adb7e5
  • Branch: claude/issue-4701-change-tournament-notifications-so-that
  • Fly App: metaculus-pr-4745-claude-issue-4701-change-tourn

ℹ️ 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
Copy Markdown
Contributor Author

@claude some unit tests are failing.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 19, 2026

Claude finished @SylvainChevalier's task in 3m 43s —— View job


Task list

  • Check CI status and identify failing tests
  • Read the failing test output
  • Reformat tests/unit/test_posts/test_jobs.py
  • Push fix

Summary

The CI failure was not in the unit tests — they all passed (725 passed, 15 skipped). The failing step was "Check Ruff formatting" in the Backend Checks job:

Would reformat: tests/unit/test_posts/test_jobs.py
1 file would be reformatted, 310 files already formatted

The offending block in the third test wrapped a Notification.objects.filter(...).count() == 1 assertion across 6 lines inside an outer assert (...), which ruff format wanted collapsed. I restructured it to match the pattern already used in the first two tests in the same file:

notifications = Notification.objects.filter(
    recipient=user2, type="post_status_change"
)
assert notifications.count() == 1

Pushed as d14f79f. CI should re-run.

Note: I don't have ruff available in this sandbox, so the fix was based on visual inspection rather than a local ruff format run. If CI still flags the file, just run uv run ruff format tests/unit/test_posts/test_jobs.py locally and push the result.
• Branch: claude/issue-4701-change-tournament-notifications-so-that

Co-authored-by: Sylvain <SylvainChevalier@users.noreply.github.com>
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.

Change tournament notifications so that users are notified when questions are published

2 participants