Skip to content

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

Merged
cnighswonger merged 2 commits into
mainfrom
feature/channel-mute-all-uploads
May 25, 2026
Merged

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

Conversation

@kanfei-code-agent
Copy link
Copy Markdown
Contributor

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.
  • Muting rain_daily additionally drops yearrainin and rainratein — both are alternate views of the same physical gauge counter (added in 73ba15d after Codex review of feat: extend per-channel mute to all outbound uploads (closes #162) #164).
  • API endpoint moves /api/cwop/mute-status/api/mute/status. UI banner + Settings panel copy broadened: "Muted channels — … in Settings → Channel Mute."

History

Reopened from closed PR #164 under the kanfei-code-agent[bot] identity so the operator can review without a self-review block. Branch and commits identical; HEAD = 73ba15d. Codex approved the prior PR after the rain-fix commit.

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 — 421 pass
  • cd frontend && npx tsc --noEmit — clean
  • cd frontend && npm run build — clean (Vite chunk-size warning 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

cnighswonger and others added 2 commits May 24, 2026 21:04
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>
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-checked HEAD 73ba15d against main. I still stand by the prior round-2 conclusion. Confirmed the migration, WU rain mute mapping, optional-auth /api/mute/status behavior, stable useMuteStatus array identity, and the CWOP compat aliases. Verification: python3 -m py_compile on touched backend files, targeted pytest (46 passed), and frontend npx tsc --noEmit.

@cnighswonger cnighswonger merged commit cbc4b65 into main May 25, 2026
5 checks passed
@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