Skip to content

feat: extend per-channel mute to all outbound uploads (closes #162)#164

Closed
cnighswonger wants to merge 2 commits into
mainfrom
feature/channel-mute-all-uploads
Closed

feat: extend per-channel mute to all outbound uploads (closes #162)#164
cnighswonger wants to merge 2 commits into
mainfrom
feature/channel-mute-all-uploads

Conversation

@cnighswonger
Copy link
Copy Markdown
Owner

Summary

  • Promotes the per-channel mute set from CWOP-only to all outbound upload services. Weather Underground is the only non-CWOP service in the repo today; future services (MQTT etc.) pull the same helper.
  • Renames the station_config keys cwop_mute_*channel_mute_* with an idempotent startup migration. One source of truth across services.
  • WU drops the directly-mapped field AND any derived field that depends on a muted sensor (e.g. mute outdoor_temperature → drops tempf, windchillf, heatindexf, dewptf). Hourly-rain DB query skipped when rain_hour is muted.
  • API endpoint moves /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.py keeps CWOP_MUTE_CHANNELS / _mute_key as compat re-exports so the cwop test module's existing imports stay valid; a small regression test asserts they point at the canonical names.
  • The migration's raw INSERT includes updated_at because the column is NOT NULL with an ORM-level default — without it, INSERT OR IGNORE silently no-ops (caught during dev; covered by the migration test).
  • WU has no 24-hour rain field, so rain_24h mute 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 — clean
  • cd frontend && npm run build — clean (Vite chunk-size warning is non-blocking per CLAUDE.md)
  • py_compile on every modified Python file — clean
  • Manual: pre-upgrade, plant a cwop_mute_outdoor_temperature=true row; restart; verify it's renamed to channel_mute_* and the banner still shows the channel as muted.
  • Manual: toggle a WU-relevant channel in Settings → Channel Mute, capture next WU upload, confirm the field (and any derived fields) are absent from the outbound params.

🤖 Generated with Claude Code

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>
Copy link
Copy Markdown

@vsits-codex-review-agent vsits-codex-review-agent Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. backend/app/services/wunderground.py:41-64 still leaves two WU rain fields outside the shared mute model. FIELD_MAP always emits yearrainin and rainratein, but _DROP_BY_CHANNEL never 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>
Copy link
Copy Markdown

@vsits-codex-review-agent vsits-codex-review-agent Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

@vsits-codex-review-agent vsits-codex-review-agent Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cnighswonger
Copy link
Copy Markdown
Owner Author

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 73ba15d. Reopened PR will reference this number.

@cnighswonger cnighswonger deleted the feature/channel-mute-all-uploads branch May 25, 2026 01:15
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