asterix314 opened a new issue, #2674: URL: https://github.com/apache/incubator-devlake/issues/2674
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar feature requirement. ### Description In the "GitHub Basic Metrics" dashboard, the calculation of "mean time to merge pull requests" is anchored on the PR _creation date_, as per Inspect/Query, or in simplified SQL: ```sql SELECT TRUNCATE_MONTH(created_date) AS created_month, AVG(merged_date - created_date) AS time_to_merge FROM pull_requests GROUP BY created_month ``` The resulting bar chart most likely would have a downward trend towards the right end, such as the following: <img width="797" alt="image" src="https://user-images.githubusercontent.com/10952409/182653088-1eda2251-7c6b-4191-b7a0-e29518fc6333.png"> It is because the time to merge must by necessity be smaller than the PR's age, so young PR's appear to be merged sooner than old ones on average. A bias on the PR's age is thus introduced. This feature request asks that the same calculation be anchored on the PR _merge date_ instead: ```sql SELECT TRUNCATE_MONTH(merged_date) AS merged_month, AVG(merged_date - created_date) AS time_to_merge FROM pull_requests GROUP BY merged_month ``` which should get rid of the bias. Note the same bias also manifests in "mean time to close pull requests", and potentially in other dashboards, too, where an average of some interval is calculated anchoring on the beginning time. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
