Skip to content

后端:notification_history 新增 trigger_source 字段并接入三处调用点 - #157

Merged
todosdev[bot] merged 2 commits into
mainfrom
tds/conv-01a180d1-be38-74e5-b0cb-88301ff8a4e9
Oct 28, 2026
Merged

todosdev[bot] merged 2 commits into
mainfrom
tds/conv-01a180d1-be38-74e5-b0cb-88301ff8a4e9

Conversation

@todosdev

@todosdev todosdev Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add trigger_source to notification history so every record shows whether it came from an item reminder, an API call, or a channel test.
  • Make POST /api/notify write history (previously it wrote none) and add channel/success/source filters to GET /me/notification-history.

Changes

  • Migrations: append schema_v2 with a nullable trigger_source column and a composite (user_id, channel, success, created_at) index.
  • Queries: insertNotificationHistory accepts trigger_source; listNotificationHistory takes ListHistoryOptions, builds a parameterized WHERE clause, and keeps the 50-default / 200-max limit.
  • Notification paths: NotifyContext carries triggerSource; API pushes tag api, scheduler reminders tag item, and channel tests tag test. Item test notifications remain NULL, outside this task's three call sites.
  • API/types: the history route parses channel, success, trigger_source, and limit; the worker record and web NotificationHistory types include the new field.
  • Tests: new worker/test/notification-history.test.ts covers writes, filters, route parsing, and both API/test writers; migration expectations were updated across the ledger and setup suites.
  • Migration note: pre-ledger databases stamp schema_v1 on the first setup call and apply schema_v2 on the next, matching existing runSetup behavior.

Testing

  • pnpm test — 19 test files, 247 tests passed.
  • pnpm typecheck — web and worker pass.
  • pnpm exec biome lint on changed files — clean; repo-wide pnpm lint exits 0 with one pre-existing warning in worker/src/routes/items.ts.

Todos added 2 commits October 28, 2026 13:06
Record item/api/test provenance, add channel/success/source filters, and update the shared web type.

Checkpoint: VsCbE0EXd7kBjUoypDpX1
Keep the local SQLite mock aligned with schema_v2 so API notification history inserts stop failing silently.

Checkpoint: NiUhYAs1Z9_CIR-v-mLMS
@todosdev
todosdev Bot merged commit 27acf28 into main Oct 28, 2026
1 check failed
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.

0 participants