Skip to content

Converge nightly place-visit scan instead of re-scanning forever - #3216

Open
Freika wants to merge 1 commit into
devfrom
fix/place-visits-job-rescan
Open

Converge nightly place-visit scan instead of re-scanning forever#3216
Freika wants to merge 1 commit into
devfrom
fix/place-visits-job-rescan

Conversation

@Freika

@Freika Freika commented Jul 25, 2026

Copy link
Copy Markdown
Owner

GitHub issue: #3150

Summary

  • The nightly PlaceVisitsCalculatingJob re-scanned the same place-nearby points forever because points that were evaluated but never formed a visit stayed visit_id: nil and were re-queried every run — pinning DB CPU for ~23h/day since 1.10.0.
  • Marks evaluated-but-visit-less points with a new nullable points.visits_scanned_at and excludes them from the month-scan trigger, so the job converges.

Migration

  • add_column :points, :visits_scanned_at, :datetime — nullable, no default, no index → instant metadata-only add (safe on the large points table). Idempotent.
  • No backfill: existing points stay visits_scanned_at: NULL, so the first post-deploy run does the one-time full scan, then converges from the second run on.

Verification

  • Regression spec fails before / passes after: the second Places::Visits::Create#call no longer re-loads the same month's points.
  • Area specs: spec/services/places/visits/create_spec.rb, spec/services/areas/visits/create_spec.rb, spec/jobs/place_visits_calculating_job_spec.rb + regression → 23 examples, 0 failures.
  • rubocop clean; CHANGELOG updated.

Review notes

  • db/schema.rb was hand-reconciled to add only the one column + version bump (Rails 8.1's dump reordered unrelated tables); please regenerate from a clean dev DB before merge.
  • Sibling Areas::Visits::Create has a similar shape but far fewer areas and no visit_id guard — left untouched (out of scope).

- Converge nightly place-visit scan instead of re-scanning forever
- Scope place-visit scan to the nearest place
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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

Review profile: CHILL

Plan: Pro Plus

Run ID: 629b5064-cf70-43e2-92ee-3aeaf4ffed84

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 fix/place-visits-job-rescan

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.

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.

1 participant