hezyin opened a new issue, #5197:
URL: https://github.com/apache/incubator-devlake/issues/5197

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and 
found no similar issues.
   
   
   ### What happened
   
   This is reported by community member Matt Arnold in Slack. He's on v0.16.0.
   
   ```
   SELECT
     DATE_ADD(date(i.creation_date), INTERVAL 
-$interval(date(i.creation_date))+1 DAY) as time,
     sum(case when i.status = ‘DONE’ then i.story_point else 0 end) as ‘Story 
Points Completed’
   FROM issues i
        join board_issues bi on i.id = bi.issue_id
        join boards b on bi.board_id = b.id
        join project_mapping pm on b.id = pm.row_id
   WHERE
     $__timeFilter(i.creation_date)
     and pm.project_name in ($project)
   group by 1
   ```
   
   Matt believes here it should use `resolution_date` instead of 
`creation_date`. And it's missing an order by statement which means that the 
data is sometimes returned in a random order which Grafana processes poorly 
(see attached picture)
   
   
![image](https://github.com/apache/incubator-devlake/assets/2908155/ac720523-b45a-49fa-afae-f4d0e4e955db)
   
   Here's his updated SQL:
   
   ```
   SELECT
     DATE_ADD(date(i.resolution_date), INTERVAL 
-$interval(date(i.resolution_date))+1 DAY) as time,
     sum(case when i.status = ‘DONE’ then i.story_point else 0 end) as ‘Story 
Points Completed’
   FROM issues i
        join board_issues bi on i.id = bi.issue_id
        join boards b on bi.board_id = b.id
        join project_mapping pm on b.id = pm.row_id
   WHERE
     $__timeFilter(i.resolution_date)
     and pm.project_name in ($project)
   group by 1
   order by time
   ```
   
   ### What do you expect to happen
   
   See above
   
   ### How to reproduce
   
   See above
   
   ### Anything else
   
   _No response_
   
   ### Version
   
   v0.16.0
   
   ### Are you willing to submit 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]

Reply via email to