Skip to content

feat: replace engagement_score with community_points aggregation#1789

Merged
bokelley merged 3 commits intomainfrom
bokelley/addie-thread-debug
Apr 1, 2026
Merged

feat: replace engagement_score with community_points aggregation#1789
bokelley merged 3 commits intomainfrom
bokelley/addie-thread-debug

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

@bokelley bokelley commented Mar 31, 2026

Summary

  • Replaces pre-computed engagement_score/excitement_score columns with on-the-fly aggregation from the community_points table across all admin tools, dashboard, stats, and account lifecycle
  • Adds tier filtering (Individual/Company) and sortable Points column to admin user dashboard
  • Adds community points breakdown to user context modal
  • Adds admin engagement query quick-match in Addie router for faster routing
  • Removes dead engagement-scoring cron job and associated DB functions (migration 345)
  • Backfills community_points table from existing data (migration 344)
  • Fixes duplicate row bug in list_users_by_engagement MCP tool via LEFT JOIN LATERAL for org deduplication

Key changes

  • MCP admin tools: list_users_by_engagement refactored with LATERAL join, new membership_tier and include_breakdown params, stage replaces lifecycle_stage
  • Admin dashboard: Tier filter dropdown, sortable Points column with accessibility (keyboard, aria-sort), points breakdown using .context-grid pattern
  • Account lifecycle: Point-based thresholds replace score-based (Connector 100pts, Champion 200pts, Pioneer 500pts)
  • Stats routes: Community points aggregation replaces engagement_score in all org/user stats

Test plan

  • TypeScript compiles clean
  • All 948 unit tests pass (84 router tests including 4 new)
  • Pre-commit hooks pass (schemas, migrations, docs, linting)
  • Code review: duplicate row bug found and fixed, NaN guard added
  • Security review: clean — all SQL parameterized, all HTML escaped, inputs validated with allowlists
  • CSS/UX review: accessibility attributes added, inline styles replaced with design system classes
  • Integration test: verify community_points aggregation matches expected values on staging
  • Verify migration 344 backfill idempotency on staging

🤖 Generated with Claude Code

bokelley and others added 2 commits April 1, 2026 08:46
Replace the stale-by-design cron-computed engagement_score column with
on-the-fly aggregation from the community_points ledger table. This gives
admins always-fresh engagement data across all surfaces.

Key changes:
- Admin dashboard: sortable Points column, tier filter (Individual/Company),
  points breakdown in user context modal
- MCP admin tools: list_users_by_engagement gains membership_tier and
  include_breakdown params, uses LATERAL join to prevent duplicate rows
- Stats/accounts routes: use community_points aggregation with
  HOT_PROSPECT_POINTS_THRESHOLD constant for consistency
- Addie router: quickMatch pattern for engagement analytics queries
- Backfill migration (338): idempotent DELETE+INSERT for all point types
- Cleanup migration (339): drop dead scoring SQL functions with correct
  parameter signatures

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…grations)

- router.ts: keep both admin analytics quick-match (ours) and greeting/react
  pattern matching (main) — independent features in the same code region
- engagement.ts: keep main's new billing fields (subscription_amount,
  subscription_interval, subscription_status, is_personal) and
  resolveMembershipTier(); use community_points aggregation instead of
  engagement_score
- Renumber migrations to 344/345 to avoid conflict with main

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bokelley bokelley changed the title feat: replace engagement_score with community_points feat: replace engagement_score with community_points aggregation Apr 1, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bokelley bokelley merged commit 939c0c1 into main Apr 1, 2026
13 checks passed
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