fix(ev): stop a manual scraper run from undoing the Spain EV handover - #124
Conversation
The rule that Spain must use exactly one EV source lived only in the scheduler. The manual CLI did not have it, so `scraper:run --country=all` would run OpenChargeMap for Spain alongside REVE - and after REVE retires those rows, a single such run puts all ~19k of them straight back. Rather than copy the rule into the CLI, both now call one function. Two copies would drift, and the drift is silent: the map just quietly fills up with duplicate Spanish chargers again. Naming EV_ES explicitly on the CLI still runs it. The CLI is a manual override and an operator asking for it by name means it.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughChangesSpain EV source selection
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change centralizes Spain’s EV-source selection rule and applies it consistently to scheduled and manual runs, preventing the manual all-country command from restoring retired duplicate chargers. No actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
Follow-up to #122, closing a foot-gun that PR left behind.
The rule that Spain must use exactly one EV source — REVE or Open Charge Map, never both — was implemented only in the scheduler (
instrumentation.ts). The manual CLI never got it. Sonpm run scraper:run -- --country=allwould happily run the Open Charge Map scraper for Spain alongside REVE, and once REVE has retired those ~19,000 rows, one such run puts every one of them straight back.The obvious fix is to copy the rule into
cli.ts. That is the wrong fix: two copies drift, and this particular drift is silent — nothing errors, the map just quietly fills back up with duplicate Spanish chargers, which is exactly the failure #122 existed to prevent.So the rule now lives in one place,
scrapers/spain-ev-source.ts, and both the scheduler and the CLI call it. The scheduler's inline copy is gone.Naming
EV_ESexplicitly on the CLI still runs it — the CLI is a manual override, and an operator asking for it by name means it. Only--country=allis collapsed.Verification
allcase, the no-Spain-EV case, and that other countries are untouched.cli.test.tsstill passes.No behaviour change for the running deployment: the scheduler path already had this rule, so production has been correct since v1.12.0. This only affects the manual CLI and removes the duplication.
Summary by CodeRabbit