Skip to content

Fix bug to track active hours across templates#72

Merged
amrit110 merged 2 commits intomainfrom
fix_active_hrs_bug
Feb 23, 2026
Merged

Fix bug to track active hours across templates#72
amrit110 merged 2 commits intomainfrom
fix_active_hrs_bug

Conversation

@amrit110
Copy link
Member

This pull request introduces improvements to how active hours are calculated and displayed per team for each template in the analytics system. The changes ensure that active hours are accurately attributed to the correct template and team, avoiding the inclusion of historical activity from other templates. The frontend and backend are updated to support and display these refined metrics.

Backend metrics calculation improvements:

  • In coder/analytics/collect.py, when initializing new usage records, total_active_hours now starts at 0.0 to prevent inheriting cross-template hours, ensuring only incremental activity is counted for each template.
  • In coder/analytics/aggregate.py, per-team active hours specific to each template are now calculated and included in the metrics output as a new team_active_hours field. [1] [2]

Frontend and types update:

  • In services/analytics/lib/types.ts, the TemplateMetrics interface is updated to include the new team_active_hours field, enabling type-safe usage throughout the frontend.
  • In services/analytics/app/template/[templateName]/template-teams-content.tsx, the display of active hours per team is updated to use the new per-template, per-team team_active_hours metric, defaulting to 0 if not present. (services/analytics/app/template/[templateName]/template-teams-content.tsxL389-R389)

@amrit110 amrit110 self-assigned this Feb 23, 2026
@amrit110 amrit110 added the bug Something isn't working label Feb 23, 2026
@amrit110 amrit110 merged commit 536ffc0 into main Feb 23, 2026
7 checks passed
@amrit110 amrit110 deleted the fix_active_hrs_bug branch February 23, 2026 16:22
@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.62%. Comparing base (715b2f8) to head (0929a5f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #72   +/-   ##
=======================================
  Coverage   90.62%   90.62%           
=======================================
  Files          10       10           
  Lines        1408     1408           
=======================================
  Hits         1276     1276           
  Misses        132      132           

☔ 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.

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.

1 participant