feat: extend per-channel mute to all outbound uploads (closes #162)#164
feat: extend per-channel mute to all outbound uploads (closes #162)#164cnighswonger wants to merge 2 commits into
Conversation
The channel-mute set introduced for CWOP/APRS in #161 now gates every outbound upload service. Weather Underground consults the same set and drops both the directly-mapped WU field and any derived field computed from a muted sensor (windchillf / heatindexf / dewptf when temperature is muted, etc.); future upload services pull the same helper. To keep one source of truth, the station_config keys are renamed ``cwop_mute_*`` → ``channel_mute_*`` with an idempotent one-shot migration in ``init_database``. API endpoint moves from ``/api/cwop/mute-status`` to ``/api/mute/status``; UI banner and Settings panel copy are broadened to reflect the wider scope. Backend - New: ``app/services/channel_mute.py`` (``MUTE_CHANNELS``, ``mute_key``, ``load_muted_channels``). - New: ``app/api/mute.py`` (replaces ``app/api/cwop.py``). - ``app/services/cwop.py`` re-exports the legacy ``CWOP_MUTE_CHANNELS`` / ``_mute_key`` symbols as compat aliases. - ``app/services/wunderground.py`` drops muted fields and derivatives; hourly-rain DB query skipped when ``rain_hour`` is muted. - ``app/models/database.py`` rename migration; uses ``CURRENT_TIMESTAMP`` for ``updated_at`` so raw SQL inserts aren't silently dropped by SQLite's NOT NULL constraint. Frontend - Hook + helpers renamed (``useMuteStatus``, ``notifyMuteChanged``); event ``channel-mute-changed``. - AppShell banner: "Muted channels — … in Settings → Channel Mute." - Settings panel: "Channel Mute — Sensor Reporting" with broadened explanatory copy. Tests - New ``tests/backend/test_wunderground.py``: per-channel direct-field drop, derived suppression for temp/humidity/wind, ``rain_24h`` no-op, hourly-rain query skip. - New ``tests/backend/test_database_migration.py``: migration of legacy keys, idempotency, no-clobber of pre-existing new-key values. - ``tests/backend/test_cwop.py`` adds compat-alias regression. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
backend/app/services/wunderground.py:41-64still leaves two WU rain fields outside the shared mute model.FIELD_MAPalways emitsyearraininandrainratein, but_DROP_BY_CHANNELnever removes them for any of the existing rain mutes. In practice that means an operator can mute every rain channel exposed by Settings (rain_daily,rain_hour,rain_24h) while a rain sensor is under repair and WU will still publish rain data via those two params. Since this PR’s UI/docs now describe the shared mute set as gating every outbound upload, I think this is still a functional gap: either one of the existing rain mutes needs to own the remaining WU-only rain params, or the feature contract needs to be narrowed explicitly.
Both fields come from the same physical rain gauge counter as dailyrainin and have no CWOP analog, so they were always emitted — defeating the mute when an operator takes a broken rain sensor out of service. Add them to the rain_daily drop list and assert. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Re-reviewed 73ba15d. Assigning \ and \ to the existing \ mute is the right operator-facing fit here: both are alternate views of the same rain-gauge signal, while \ remains the separate one-hour accumulation query. No remaining blocking issues from my prior review.
There was a problem hiding this comment.
Re-reviewed 73ba15d. Assigning yearrainin and rainratein to the existing rain_daily mute is the right operator-facing fit here: both are alternate views of the same rain-gauge signal, while rain_hour remains the separate one-hour accumulation query. No remaining blocking issues from my prior review.
|
Reopening under the kanfei-code-agent bot identity — original PR was inadvertently authored by the operator account, which blocks self-review. Branch and commits unchanged; HEAD remains |
Summary
station_configkeyscwop_mute_*→channel_mute_*with an idempotent startup migration. One source of truth across services.tempf,windchillf,heatindexf,dewptf). Hourly-rain DB query skipped whenrain_houris muted./api/cwop/mute-status→/api/mute/status. UI banner + Settings panel copy broadened: "Muted channels — … in Settings → Channel Mute."Notes for reviewers
backend/app/services/cwop.pykeepsCWOP_MUTE_CHANNELS/_mute_keyas compat re-exports so the cwop test module's existing imports stay valid; a small regression test asserts they point at the canonical names.INSERTincludesupdated_atbecause the column is NOT NULL with an ORM-level default — without it,INSERT OR IGNOREsilently no-ops (caught during dev; covered by the migration test).rain_24hmute is a no-op for WU. Tested.Test plan
cd backend && python -m pytest ../tests/backend/ -q— 420 pass (was 401; +19 from new test_wunderground + test_database_migration suites and a compat-alias regression)cd frontend && npx tsc --noEmit— cleancd frontend && npm run build— clean (Vite chunk-size warning is non-blocking per CLAUDE.md)py_compileon every modified Python file — cleancwop_mute_outdoor_temperature=truerow; restart; verify it's renamed tochannel_mute_*and the banner still shows the channel as muted.🤖 Generated with Claude Code