Skip to content

Conversation

@amrit110
Copy link
Member

This pull request improves the accuracy of active hours aggregation in analytics metrics by introducing a new function to correctly sum user active hours across workspaces. The main change ensures that active hours are not overcounted for users with multiple workspaces, and that each user's active hours are capped at their total workspace hours. This logic is now consistently applied in team and template metrics calculations. Additionally, a clarifying comment was added to the backend script to explain the semantics of active hours.

Active hours aggregation improvements:

  • Added a new calculateTotalActiveHours function in metrics.ts to aggregate active hours per user, capping each user's active hours at their total workspace hours to prevent overcounting.
  • Updated aggregateByTeam to use the new aggregation logic for total active hours, replacing the previous simple sum.
  • Updated calculateTemplateMetrics to use the new aggregation logic for total active hours, ensuring consistency across analytics.

Documentation and clarity:

  • Added a clarifying comment in collect_coder_analytics.py explaining that active_hours is per-user (not per-workspace) and that frontend aggregation counts each user only once.

@amrit110 amrit110 self-assigned this Dec 10, 2025
@amrit110 amrit110 added the bug Something isn't working label Dec 10, 2025
@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.09%. Comparing base (f0c6c64) to head (0243938).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #46   +/-   ##
=======================================
  Coverage   88.09%   88.09%           
=======================================
  Files           3        3           
  Lines         462      462           
=======================================
  Hits          407      407           
  Misses         55       55           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@amrit110 amrit110 merged commit cfffbd2 into main Dec 10, 2025
8 checks passed
@amrit110 amrit110 deleted the bug_fixes branch December 10, 2025 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants