Email opt-outs respected, and stats counted by year
Why it matters: Players who turn off tournament emails stay opted out, and their stats for a year reflect only that year's events.
If you turned off tournament update emails, the settings page could still show the box as ticked. Saving your settings again for any reason then turned the emails back on. The settings page now shows your choice correctly, and tournament emails, group emails and the count of who will receive them now follow one rule: you get them only if you have clearly said yes.
Player stats for a year now count only that year’s events. Before, each year’s stats included events from every year. Stats saved before this change need a one-time recalculation before they show the corrected figures.
We also made running a tournament more dependable:
- When a tournament goes live and some teams’ scores can’t be set up, the tournament still goes live, and the site administrator sees which teams need attention and why.
- Fetching live scores now stops waiting after a set time, so a slow response from the scores source doesn’t hold up updates.
- Golfer results can only be edited while a tournament is live.
Under the hood: Each team’s score setup runs as its own step, so one failure no longer stops the rest. Automated tests cover the new email rule from the settings page through to sending, and we broke each covered rule on purpose to check that a test would catch it.
Commits (1)
-
70e48fdPhase 4 part 2: per-year stats, honoured opt-outs, go-live warnings, ESPN timeouts
Files Changed (19)
app/controllers/admin/event_emails_controller.rb | 2 +- app/controllers/admin/events_controller.rb | 34 +++++++++++++++- app/controllers/admin/golfer_results_controller.rb | 2 + app/controllers/admin/group_emails_controller.rb | 7 +--- app/jobs/send_event_emails_job.rb | 8 +--- app/models/user.rb | 13 ++++++ app/services/tournament_scraper_service.rb | 3 +- app/services/tournament_state_service.rb | 29 ++++++++++++-- app/services/user_tournament_stats_service.rb | 8 ++-- app/views/user_profiles/settings.html.erb | 2 +- docs/background_jobs.md | 34 +++++++++------- test/controllers/admin/emails_coverage_test.rb | 23 +++++++++++ test/controllers/admin/events_coverage_test.rb | 68 ++++++++++++++++++++++++++++++ .../notification_settings_round_trip_test.rb | 42 +++++++++++++++++++ test/jobs/send_event_emails_job_test.rb | 7 ++-- test/models/user_notification_preferences_test.rb | 34 +++++++++++++++ test/services/tournament_scraper_service_test.rb | 3 +- .../tournament_state_service_coverage_test.rb | 34 ++++++++++++---- .../user_tournament_stats_service_test.rb | 28 +++++++++---- 19 files changed, 322 insertions(+), 59 deletions(-)