devstats icon indicating copy to clipboard operation
devstats copied to clipboard

Fix PR-Time-To-Merge median calculation for aggregated periods

Open Arunodoy18 opened this issue 1 month ago • 2 comments

Replace percentile_disc(0.5) with avg() for median calculations to prevent misleading results when aggregating over larger time intervals. This addresses the issue where medians calculated over extended periods showed inflated values due to incorrect aggregation method.

Changes:

  • Replace percentile_disc(0.5) with avg() for all median calculations
  • Preserve percentile_disc(0.85) for 85th percentile calculations
  • Apply fixes to both time_metrics.sql and time_metrics_repos.sql
  • Maintain filter conditions for API change classifications

The avg() approach provides more accurate median aggregation over time periods and is computationally more efficient than percentile_disc().

Fixes: Kubernetes PR-Time-To-Merge median aggregation over larger intervals

Please make sure that you follow instructions from CONTRIBUTING

Specially:

  • Check if all tests pass, see TESTING for deatils.
  • Make sure you've added test coverage for new features/metrics.
  • Make sure you have updated documentation.
  • If you added a new metric, please make sure you have been following instructions about adding new metric.

Arunodoy18 avatar Nov 24 '25 23:11 Arunodoy18

I have done all the changes and the fixes . Thank you

Arunodoy18 avatar Nov 24 '25 23:11 Arunodoy18

Hi, thanks for this, I will get to this on my CNCF working day. Please note that changing SQL means that given dashboard must be manually regenerated for given project(s), that means:

  • I need to test if fix work first.
    • Then I need to regenerate pre-computed data for all projects that were modified.
  • We're now doing a migration to new servers which may be higher priority.
  • I have two weeks of vacation between Dec 4th - Dec 17th.

Just note that I will eventually work on this one, but it may take some time.

lukaszgryglicki avatar Nov 25 '25 05:11 lukaszgryglicki

Any further Updates?

Arunodoy18 avatar Dec 02 '25 15:12 Arunodoy18

I will work on this after migration as already mentioned on other tickets.

lukaszgryglicki avatar Dec 02 '25 16:12 lukaszgryglicki