Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug][Grafana] PR Cycle TIme doesn't Respect Time Interval #6944

Closed
2 of 3 tasks
ldmoose opened this issue Feb 8, 2024 · 1 comment · Fixed by #7052
Closed
2 of 3 tasks

[Bug][Grafana] PR Cycle TIme doesn't Respect Time Interval #6944

ldmoose opened this issue Feb 8, 2024 · 1 comment · Fixed by #7052
Assignees
Labels
type/bug This issue is a bug

Comments

@ldmoose
Copy link

ldmoose commented Feb 8, 2024

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

Working:
image

Not Working:
image

What do you expect to happen

I expect that when the time interval option in the board changes that the PR Cycle Time graph respects that change.

How to reproduce

  1. Go to https://devlake.apache.org/livedemo/EngineeringLeads/EngineeringThroughputAndCycleTime
  2. Change Time Interval to 'Week'
  3. The Pr Cycle Time doesn't respect the change

Anything else

Problem is here: https://github.com/apache/incubator-devlake/blob/main/grafana/dashboards/EngineeringThroughputAndCycleTime.json#L1161

Specifically, in the main select statement, the first column definition (and the subsequent group by) should have INTERVAL -$interval(date(pr_issued_date))+1 DAY as the second function parameter in the DATE_ADD function call.

WITH _prs AS (
  SELECT pr.id
    , pr.created_date AS pr_issued_date
    -- convert null to 0 if a PR has no cycle_time to make sure cycle_time equals the sum of the four metrics below
    , COALESCE(prm.pr_cycle_time/60,0) AS cycle_time
FROM pull_requests pr
LEFT JOIN project_pr_metrics prm ON pr.id = prm.id
INNER JOIN project_mapping pm ON pr.base_repo_id = pm.row_id AND pm.table = 'repos'
WHERE $__timeFilter(pr.created_date)
AND pr.created_date >= DATE_ADD(DATE_ADD($__timeFrom(), INTERVAL -DAY($__timeFrom())+1 DAY), INTERVAL +1 MONTH)
AND pm.project_name in (${project:sqlstring}+'')
GROUP BY pr.id
  , pr.created_date
  , COALESCE(prm.pr_cycle_time/60,0)
)

SELECT 
  DATE_ADD(date(pr_issued_date), INTERVAL -DAYOFMONTH(date(pr_issued_date))+1 DAY) AS time
  , AVG(cycle_time) AS 'PR Cycle Time(h)'
FROM _prs
GROUP BY DATE_ADD(date(pr_issued_date), INTERVAL -DAYOFMONTH(date(pr_issued_date))+1 DAY)
ORDER BY time

Version

Latest: v0.19.0

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@ldmoose ldmoose added the type/bug This issue is a bug label Feb 8, 2024
@abeizn
Copy link
Contributor

abeizn commented Feb 9, 2024

@ldmoose Thanks a lot, we will fix it in v0.21.0-beta7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug This issue is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants