feat: replace engagement_score with community_points aggregation#1789
Merged
feat: replace engagement_score with community_points aggregation#1789
Conversation
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>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
engagement_score/excitement_scorecolumns with on-the-fly aggregation from thecommunity_pointstable across all admin tools, dashboard, stats, and account lifecycleengagement-scoringcron job and associated DB functions (migration 345)community_pointstable from existing data (migration 344)list_users_by_engagementMCP tool viaLEFT JOIN LATERALfor org deduplicationKey changes
list_users_by_engagementrefactored with LATERAL join, newmembership_tierandinclude_breakdownparams,stagereplaceslifecycle_stage.context-gridpatternTest plan
🤖 Generated with Claude Code