Skip to content

Various visit creation improvements#2284

Merged
Freika merged 2 commits intoFreika:devfrom
nareddyt:tnareddy/fix-visits
Mar 19, 2026
Merged

Various visit creation improvements#2284
Freika merged 2 commits intoFreika:devfrom
nareddyt:tnareddy/fix-visits

Conversation

@nareddyt
Copy link
Contributor

@nareddyt nareddyt commented Feb 21, 2026

Some improvements to the visit suggestion job based on behavior I see in my dawarich deployment.

  • Performance: Move reverse decoding for places from app/models/visit.rb into app/services/visits/suggest.rb, allowing us to deduplicate.
  • Deduplication: app/services/visits/creator.rb: For visits, check for any existing visit (confirmed, suggested, or declined). This prevents duplicating suggested visits, especially in cases where new points are imported after the nightly visit suggestion job runs.
    • @Freika any idea why this was originally only implemented for confirmed visits? IMO the distinction is not needed, and the logic works well on all visits.
  • Correctness: app/services/visits/creator.rb: visits.map continues with nil if the visit is pre-existing. This prevents running create_visits_notification if all visits are pre-existing.
  • Readability:app/services/visits/creator.rb: Simplify the time check for existing visits.
  • Correctness: app/services/visits/creator.rb: Use visit.center which supports calculating the center of visit from area, place, and falls back to points.
    • This is needed because sometimes visits do not have areas/places associated with them.
    • I am not 100% sure why this is possible, but I had visits in my database with this condition. So let's use the known fallback (calculate visit center from points).

@coderabbitai
Copy link

coderabbitai bot commented Feb 21, 2026

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

Run ID: b0dd7ea0-7131-45b6-b940-52ab3538d7b1

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
  • Post copyable unit tests in a comment
📝 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.

Tip

CodeRabbit can use OpenGrep to find security vulnerabilities and bugs across 17+ programming languages.

OpenGrep is compatible with Semgrep configurations. Add an opengrep.yml or semgrep.yml configuration file to your project to enable OpenGrep analysis.

Resolve visit creator conflict by keeping all-status deduplication with visit.center fallback and interval-overlap matching.

Made-with: Cursor
@Freika Freika merged commit 0306c21 into Freika:dev Mar 19, 2026
2 of 3 checks passed
@Freika
Copy link
Owner

Freika commented Mar 19, 2026

Thanks for the contribution!

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