Skip to content

fix: populate keyTrends in AI insights was always returning empty array#79

Open
ayuxsh009 wants to merge 1 commit into
seetadev:mainfrom
ayuxsh009:fix/ai-key-trends-empty
Open

fix: populate keyTrends in AI insights was always returning empty array#79
ayuxsh009 wants to merge 1 commit into
seetadev:mainfrom
ayuxsh009:fix/ai-key-trends-empty

Conversation

@ayuxsh009

Copy link
Copy Markdown

Description

This PR fixes an issue where the keyTrends array in generateAIInsights (src/lib/ai.ts) was always returned as an empty array.

Although the function generated values for achievements, areasOfConcern, and recommendations, no logic existed to populate keyTrends, causing the “Key Trends” section in the UI to remain permanently blank.

This update adds meaningful trend insights derived from existing analytics data and removes duplicate calculations to improve maintainability.

Fixes #78


Changes

  • Fix
  • Populated keyTrends with real analytical insights
  • Added week-over-week contribution trend analysis
  • Added engagement rate and NPS trend reporting
  • Added tech partner collaboration metrics
  • Added issue completion trend summaries
  • Added contributor activity trend insights
  • Removed duplicate latestIssues and completionRate calculations
  • Refactored shared analytics computation logic

📷 Screenshots / Demo (if applicable)

N/A — backend AI insight generation fix.


🔍 Additional Notes

Problem

keyTrends was initialized but never populated:

const keyTrends: string[] = [];

As a result:

  • The Key Trends UI section always appeared empty
  • The returned AIInsights object was incomplete
  • Consumers could incorrectly assume no trends existed

Solution

This PR now generates 6 factual trend observations using existing analytics data already available in the function, including:

  • Week-over-week contribution movement
  • Engagement rate analysis
  • Program NPS score trends
  • Active tech partner collaboration
  • Issue completion metrics
  • Contributor activity summaries

Refactor

Duplicate calculations for:

  • latestIssues
  • completionRate

were consolidated into shared computations to avoid redundant processing and improve readability.

Files Changed

  • src/lib/ai.ts (modified)

Checklist

  • I have tested this code
  • I have added necessary documentation
  • I have linked relevant issue(s)
  • I followed the code style of the project
  • I reviewed my own code

@vercel

vercel Bot commented May 9, 2026

Copy link
Copy Markdown

@ayuxsh009 is attempting to deploy a commit to the SEETA's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

bug: populate missing keyTrends data in AI insights generation

1 participant