Skip to content

fix(analytics): totalFollows now counts followers received, not follows performed#448

Open
Srejoye wants to merge 1 commit into
Dev-Card:mainfrom
Srejoye:fix/analytics-totalfollows-inbound-count
Open

fix(analytics): totalFollows now counts followers received, not follows performed#448
Srejoye wants to merge 1 commit into
Dev-Card:mainfrom
Srejoye:fix/analytics-totalfollows-inbound-count

Conversation

@Srejoye
Copy link
Copy Markdown
Contributor

@Srejoye Srejoye commented Jun 1, 2026

Summary

Fixes #435

The totalFollows field in GET /api/analytics/overview was querying FollowLog with followerId: userId, which counts follows the authenticated user performed on others — the exact opposite of what the dashboard intends to show.

Changes

  • Extract username from the JWT payload alongside the existing id
  • Replace the followLog.count filter to use targetUsername: username so the metric reflects how many other users have successfully followed the current user
  • No response shape change — totalFollows field name is preserved; its semantic is now correct

Testing

  • Existing analytics tests updated to assert inbound-follow semantics
  • Added seed fixture: User A follows authenticated user (counted), authenticated user follows User B (must not be counted)
  • Verified totalFollows returns 0 when no one has followed the user, even if the user has followed many others

Notes

The JWT payload already includes username (set in both authRoutes and connectRoutes at sign time), so no auth changes are required.

@Harxhit Harxhit added the gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking. label Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: GET /api/analytics/overviewtotalFollows counts follows *performed by* the user, not follows *received* by the user

2 participants