RadarStore: use mounted data_dir so deploys don't wipe radars#37
Merged
Conversation
After the radar PR shipped, every deploy wiped users' radar listings — they had to re-opt-in to repopulate. Portfolios survived because Pulse.Store reads `data_dir` from config and `config/runtime.exs` points that at `DATA_DIR=/app/data`, a Kamal-mounted volume. RadarStore was the odd one out: it called `:code.priv_dir(:pulse)` directly, which resolves inside the release directory — rebuilt per image, so the file was always empty after a deploy. Match the pattern used by `Pulse.Store`, `Pulse.Analytics`, and `Pulse.RadarAnalytics`: read `data_dir` from app env and join `radars.dets` onto it. In prod that resolves to `/app/data/radars.dets` (volume-backed); in dev it stays at `priv/data/radars.dets`; in test the data_dir is already overridden in `config/test.exs`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
After the radar PR shipped, every Pulse deploy wiped users' radar listings — they had to re-opt-in (re-toggle Share Radar in Quantic, or wait for the next `radar.updated` event) to see their radar reappear. Portfolios survived deploys fine.
Root cause
RadarStorewas the odd one out among DETS-using modules: it called `:code.priv_dir(:pulse)` directly to locate `radars.dets`, which resolves inside the release directory. Kamal rebuilds the release per image, so the file was always empty after a deploy.Every other DETS user (`Pulse.Store`, `Pulse.Analytics`, `Pulse.RadarAnalytics`) reads `data_dir` from app env, which `config/runtime.exs` overrides via the `DATA_DIR` env var → `/app/data` in prod, a Kamal-mounted volume that persists across deploys.
Fix
Make
RadarStore.init/1read the configurable `data_dir` and join `radars.dets` onto it. One-line equivalence with the other modules.Migration note for this deploy
This deploy will start with an empty `/app/data/radars.dets` because the file was never written to that location before. The radar workers currently in memory (re-opted-in after the last deploy) live only in the old `priv/data/` path inside the running container, which goes away when the new image takes over.
Two options to preserve current radar state across this deploy:
```
kamal app exec --reuse -- cp /app/lib/pulse-/priv/data/radars.dets /app/data/radars.dets
```
(Path inside the release tree — check with `kamal app exec --reuse -- find /app -name radars.dets` first.)
Test plan
mix test— 44 / 44mix format --check-formatted— cleanmix compile --warnings-as-errors— clean🤖 Generated with Claude Code