Files
notify-bridge/plans/entity-relationship-refactor/phase-2-notification-tracker-rename.md
T
alexei.dolgolyov 1d445f3980 feat: entity relationship refactor — notification trackers, command system, chat actions
Rework entity schema: rename Tracker→NotificationTracker, add CommandConfig/
CommandTracker/CommandTrackerListener entities for decoupled command handling.
Commands now resolve through CommandTracker→CommandConfig instead of
TelegramBot.commands_config. Smart ref-counted bot polling based on active
listeners. Add chat_action to telegram targets. Full frontend CRUD pages
for command configs and command trackers. Idempotent SQLite migrations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 01:27:20 +03:00

61 lines
4.1 KiB
Markdown

# Phase 2: Notification Tracker Rename (API)
**Status:** ⬜ Not Started
**Parent plan:** [PLAN.md](./PLAN.md)
**Domain:** backend
## Objective
Rename all tracker-related API routes, service functions, and internal references to use
"notification_tracker" naming. Add chat_action support to the targets API. Ensure the
watcher, scheduler, and notifier services work with the renamed models.
## Tasks
- [ ] Task 1: Rename `api/trackers.py``api/notification_trackers.py`. Update all route paths from `/api/trackers` to `/api/notification-trackers`. Update function names (e.g., `list_trackers``list_notification_trackers`). Update all model references to use `NotificationTracker`.
- [ ] Task 2: Rename `api/tracker_targets.py``api/notification_tracker_targets.py`. Update route paths from `/api/tracker-targets` to `/api/notification-tracker-targets`. Update model references to `NotificationTrackerTarget`, field references to `notification_tracker_id`.
- [ ] Task 3: Update `api/targets.py` — add `chat_action` to create/update request schemas and response serialization for telegram-type targets.
- [ ] Task 4: Update `services/watcher.py` — replace all `Tracker` references with `NotificationTracker`, `TrackerTarget` with `NotificationTrackerTarget`, `TrackerState` with `NotificationTrackerState`, `tracker_id` with `notification_tracker_id` where applicable.
- [ ] Task 5: Update `services/scheduler.py` — rename tracker job references, function parameters, and log messages to use notification_tracker naming.
- [ ] Task 6: Update `services/notifier.py` — update model references and any tracker-related parameter names.
- [ ] Task 7: Update `main.py` — change router imports and registration to use new module names and route prefixes.
- [ ] Task 8: Update `api/status.py` — rename any tracker count queries to use new model names.
- [ ] Task 9: Update `commands/handler.py` — update any tracker model references used for command context resolution.
- [ ] Task 10: Update `commands/webhook.py` — update any tracker model references.
- [ ] Task 11: Update `services/telegram_poller.py` — update any tracker model references.
- [ ] Task 12: Remove backward-compatibility aliases from models.py (if added in Phase 1) — all consumers now use new names.
## Files to Modify/Create
- `packages/server/src/notify_bridge_server/api/trackers.py` → rename to `notification_trackers.py`
- `packages/server/src/notify_bridge_server/api/tracker_targets.py` → rename to `notification_tracker_targets.py`
- `packages/server/src/notify_bridge_server/api/targets.py` — add chat_action
- `packages/server/src/notify_bridge_server/services/watcher.py` — model name updates
- `packages/server/src/notify_bridge_server/services/scheduler.py` — model name updates
- `packages/server/src/notify_bridge_server/services/notifier.py` — model name updates
- `packages/server/src/notify_bridge_server/main.py` — router registration
- `packages/server/src/notify_bridge_server/api/status.py` — model name updates
- `packages/server/src/notify_bridge_server/commands/handler.py` — model references
- `packages/server/src/notify_bridge_server/commands/webhook.py` — model references
- `packages/server/src/notify_bridge_server/services/telegram_poller.py` — model references
## Acceptance Criteria
- All API routes work under new `/api/notification-trackers` and `/api/notification-tracker-targets` paths
- Old `/api/trackers` routes no longer exist
- Telegram targets accept and return `chat_action` field
- Server starts and health check passes
- Watcher/scheduler/notifier services function correctly with renamed models
## Notes
- This is a breaking API change — frontend will need updating in Phase 5.
- The watcher service is the most complex consumer of tracker models — test carefully.
- The EventLog model references notification_tracker_id (renamed in Phase 1).
## Review Checklist
- [ ] All tasks completed
- [ ] Code follows project conventions
- [ ] No unintended side effects
- [ ] Build passes
- [ ] Tests pass (new + existing)
## Handoff to Next Phase
<!-- Filled in by the implementation agent after completing this phase. -->