#120 · Refactor: share community-rollup logic between !rollup --full and 02:00 cron
cp .dev.vars.example .dev.vars && pnpm dev, after rebasing on main) and fully test your change before opening the MR.
Description
Context
Two implementations of "build a 7-day community rollup → publish to Outline" exist in the signal-bot:
apps/signal-bot/src/src/bot/command-handler.ts:handleRollup— user-triggered via!rollup --full. Has rate-limit, admin gate,featureDisabled('docs publishing')graceful-degradation, configurable period,--fulldetail queries.
apps/signal-bot/src/src/utils/community-rollup.ts:generateAndStoreCommunityRollup— cron-triggered at 02:00 ET. Lacks all of the above guards because the cron runs trusted.
Same 8 stat queries, similar markdown construction, both POST to Outline. Future stat additions or markdown improvements will land in one and not the other (architecture review C1, commit 2139c12a).
Acceptance criteria
- [ ] Extract
fetchCommunityRollupStats(dbClient, queryOptions): Promise<CommunityRollupStats>toapps/signal-bot/src/src/utils/community-rollup.ts— does the 8 parallelgetRollup*Statsqueries withPromise.all(already done in cron version) - [ ] Extract
buildCommunityRollupMarkdown(stats, opts: { title; periodLabel; sinceLabel; untilLabel; includeDetails? })— produces the markdown body (no Outline calls). TheincludeDetailsflag covers the--fulldetail-query expansion paths. - [ ] Refactor
command-handler.ts:handleRollupto call the new shared functions. Keep all admin/gate/rate-limit logic at the handler layer. - [ ] Refactor
community-rollup.ts:generateAndStoreCommunityRollupto call the new shared functions. Keep persistence + Outline-doc creation at the cron layer. - [ ] Add at least one test asserting both paths produce identical markdown for the same stats input.
- [ ] Verify the existing
--fullSignal-bot command still works after refactor (smoke test: admin runs!rollup --fullin DM, gets the same Outline doc shape as before).
Technical hints
- Today's commit
2139c12aremoved theas anycasts so the dbClient signatures are now honest. - Keep
buildCommunityRollupMarkdownpure (no I/O) so it's easy to unit-test. - The
command-handlerversion awards points for--fulland the cron version does not — that's a real difference, document the divergence in the new function or the call site.
--- *M-tier (100 pts + 40 merge_pr = 140). Cleanup of recent feature work; will keep the rollup shape consistent across surfaces.*
Getting Started (added for pickup-readiness)
Path note: apps/signal-bot/src/src/... is pre-move; the live tree is
selfhost/messaging-apps/signal-messenger/src/src/....
- Files:
src/src/utils/community-rollup.ts(extract the shared fns here) and - Existing test to extend:
src/src/tests/utils/community-rollup.test.ts— add the - Verify:
cd selfhost/messaging-apps/signal-messenger/src && npx vitest runthen - Coordinate: pairs with #119 — landing #119 first gives a regression net for this refactor.
src/src/bot/command-handler.ts:handleRollup (refactor to consume them).
markdown-parity assertion here.
npx tsc --noEmit; smoke-test !rollup --full as admin in a DM.
Prepared for pickup by 🤖 GearSmith's Goal-Tender (Claude).
Relevant files
No relevant files linked yet.
Hints
No hints yet.
Activity
No points have been awarded for this bounty yet.
Comments
Sign in to join the discussion.
No comments yet. Be the first to weigh in.