Fix digest email showing "0 replies / 0 reactions" for every event #23

Merged
matt merged 1 commit from mailship-d08-digest-email-shows-0-replies-0-reactions-10f into main 2026-09-18 15:37:54 +00:00
Collaborator

mailship-d08

Digest email shows "0 replies / 0 reactions" for every event because the context used to compute reply/reaction counts was set to [...events] — a placeholder that included no reply or reaction events.

Changes

In sendFromStoredEvents, the temporary context = [...events] (with the comment "no reply loading") is replaced by a real query against the repository for events that tag our matched event IDs with kinds NOTE, COMMENT, or REACTION. The resulting reply/reaction events are included in context, so repliesByParentId in buildParameters actually finds entries and produces correct counts.

src/digest.ts — import repository and query it for #e-tagged context events.

test/digest-reply-stats.test.ts — new test that publishes reply and reaction events into a mock repository, calls sendFromStoredEvents, and asserts that the rendered digest parameters show Replies >= 1 and Reactions >= 1.

How to test

pnpm run test:unit -- --run test/digest-reply-stats.test.ts

The test exercises the fix by publishing reply/reaction events to the repository before triggering a digest send. Without the fix, the mock repository query returns nothing and Replies/Reactions remain 0.

mailship-d08 Digest email shows "0 replies / 0 reactions" for every event because the `context` used to compute reply/reaction counts was set to `[...events]` — a placeholder that included no reply or reaction events. **Changes** In `sendFromStoredEvents`, the temporary `context = [...events]` (with the comment "no reply loading") is replaced by a real query against the repository for events that tag our matched event IDs with kinds `NOTE`, `COMMENT`, or `REACTION`. The resulting reply/reaction events are included in `context`, so `repliesByParentId` in `buildParameters` actually finds entries and produces correct counts. `src/digest.ts` — import `repository` and query it for `#e`-tagged context events. `test/digest-reply-stats.test.ts` — new test that publishes reply and reaction events into a mock repository, calls `sendFromStoredEvents`, and asserts that the rendered digest parameters show `Replies >= 1` and `Reactions >= 1`. **How to test** ```bash pnpm run test:unit -- --run test/digest-reply-stats.test.ts ``` The test exercises the fix by publishing reply/reaction events to the repository before triggering a digest send. Without the fix, the mock repository query returns nothing and `Replies`/`Reactions` remain 0.
hudson added 1 commit 2026-09-18 14:48:39 +00:00
fix: load reply/reaction events from repository into digest context
All checks were successful
CI / checks (pull_request) Successful in 34s
ae836da033
Instead of setting context = events (which made repliesByParentId always
empty), query the repository for events that #e-tag our matched event
IDs with kinds NOTE, COMMENT, or REACTION. This gives buildParameters
real reply/reaction data to count.

Fixes the bug where every event in the digest email showed
'0 replies / 0 reactions'.

Added test/digest-reply-stats.test.ts that:
- Publishes reply and reaction events into a mock repository
- Calls sendFromStoredEvents with only the parent event
- Asserts that the resulting digest parameters show Replies >= 1 and
  Reactions >= 1
matt approved these changes 2026-09-18 15:37:50 +00:00
matt merged commit e22a5f457e into main 2026-09-18 15:37:54 +00:00
matt deleted branch mailship-d08-digest-email-shows-0-replies-0-reactions-10f 2026-09-18 15:37:58 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: matt/mailship#23
No description provided.