Startrekzky commented on issue #4217:
URL: 
https://github.com/apache/incubator-devlake/issues/4217#issuecomment-1445626805

   Hi @GSoul-hub , I haven't thought of a general solution for this. However, 
we started collecting Jira issue labels in v0.16, which will be released soon. 
This version brings a workaround for you by changing the SQL in the DORA 
dashboard. Please follow the steps below:
   
   1. Go to the DORA dashboard, `Edit` the Median time to restore service
   
![image](https://user-images.githubusercontent.com/14050754/220827059-e4106476-0f9c-4a66-9dec-3e671a2201c1.png)
   
   
   2. As you can see, the existing SQL to get incidents looks like below. See 
other examples SQL in [this 
doc](https://devlake.apache.org/zh/docs/next/Metrics/MTTR#how-is-it-calculated)
   
   ```
   -- Metric 3: Median time to restore service 
   with _incidents as (
   -- get the incidents created within the selected time period in the 
top-right corner
        SELECT
          cast(lead_time_minutes as signed) as lead_time_minutes
        FROM
          issues i
          join board_issues bi on [i.id](http://i.id/) = bi.issue_id
          join boards b on bi.board_id = [b.id](http://b.id/)
          join project_mapping pm on [b.id](http://b.id/) = pm.row_id
        WHERE
          pm.project_name in ($project)
          and i.type = 'INCIDENT'
          and $__timeFilter(i.created_date)
   ),
   
   ...
   ```
   
   You can update it based on your own definition by joining table 
[issue_labels](https://devlake.apache.org/zh/docs/DataModels/DevLakeDomainLayerSchema#issue_labels).
 For example,
   
   ```
   -- Metric 3: Median time to restore service 
   with _incidents as (
   -- get the incidents created within the selected time period in the 
top-right corner
        SELECT
             -- please add a distinct here
             distinct [i.id](http://i.id/),
          cast(lead_time_minutes as signed) as lead_time_minutes
        FROM
          issues i
          join board_issues bi on [i.id](http://i.id/) = bi.issue_id
          join boards b on bi.board_id = [b.id](http://b.id/)
          join project_mapping pm on [b.id](http://b.id/) = pm.row_id
             -- add a new join here
             left join issue_labels il on [i.id](http://i.id/) = il.issue_id
        WHERE
          pm.project_name in ($project)
             -- change the definitions of incidents 
          and i.type = 'bug'
             and il.name = 'production'
          and $__timeFilter(i.created_date)
   ),
   
   ...
   ```
   
   I hope it helps.


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