Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The SQL for JIRA Progress Custom Field is a convenient way to show percentage values as well as a label beside the bar.

...

  • Value: a decimal number between 0 and 1. It represents the progress.
  • Label: A free text shown on the right of the bar
  • MinColour: Color for the value 0.
  • MaxColour: Color for the value 1.
  • Fill: The colors representing the progress.   (Not valid since version 3.0.x)

Example:


select SELECT '3393.3%8%' as "label",
0.333 938 as "value", '{gradient:["green", "yellow", "red"]}' as fill
'#FF0000' AS minColour,
'#00FF00' AS maxColour
from issues i
where i.key= ?

 

The fill column is quite customizable with solid colors as well as gradients. Examples:

  • { color: "#ff1e41" } 
  • { color: 'rgba(255, 255, 255, .3)' } 
  • { gradient: ["red", "green", "blue"] } 
  • { gradient: [["red", .2], ["green", .3], ["blue", .8]] } 
  • { gradient: [ ... ], gradientAngle: Math.PI / 4 } 
  • { gradient: [ ... ], gradientDirection: [x0, y0, x1, y1] } 

...

'${key}'


Example

Suppose our issues are divided into subtasks. This is common when our tasks require the completion of several processes to be able to solve them. We may need an analysis, testing, I+D ...

...

The first step is to get the query to get the parameters' label, 'value', 'minColor' and 'grillmaxColor' that our custom field needs, and for this we help from the add-on SQL for JIRA Driver.

We open the SQL for JIRA Driver console and build our sql:


Section


Column
width45%

Image RemovedImage Added


Column
width45%

Image RemovedImage Added



We get the following sql:

Code Block
languagesql
titlePercentage of subtasks performed
SELECT
(CAST(resolutions.solved AS FLOAT) / CAST(totals.total AS FLOAT)) AS VALUE,
  concat(CAST((CAST(resolutions.solved AS FLOAT) / CAST(totals.total AS FLOAT))*100 AS VARCHAR(5)), '%') AS label,
  '{gradient:["red", "yellow", "green"]}'#FF0000' AS minColour, 
  '#00FF00' AS fillmaxColour

FROM
  (
    SELECT
      ifnull(NULLIF(COUNT(*), 0), 1) AS total 
    FROM
      issues i 
      INNER JOIN
        issuesubtasks isb 
        ON isb.parentid = i.id 
    WHERE
      i.jql = 'issue = ${key}' 
  )
  totals,
  (
    SELECT
      COUNT(*) AS solved 
    FROM
      issues i 
    WHERE
      i.jql = 'parent = ${key} and resolution is not EMPTY' 
  )
  resolutions

...

Warning
titleChange Issue Identifier

As can be seen, the query of the image has been made for a particular issue, in this case the issue with identifier 10201 DEMO-6. But we want to calculate the percentage for the issue that is being displayed in JIRA at that time. Therefore, we need to take the key of the issue as a variable. For this, we replace the identifier 10201 DEMO-6 with the expression ${key}. The add-on is smart enough to replace the value of the expression with the identifier of the issue being displayed.

...

Section


Column
width45%


Column
width45%

Image RemovedImage Added



With these simple steps, we already have our custom field that measures the percentage of subtasks resolved in an issue.


Section


Column
width30%

Image RemovedImage Added


Column
width30%

Image RemovedImage Added


Column
width30%

Image RemovedImage Added



As you can see, it is easy to use the custom field, you just have to get the appropriate SQL for the information that we want to display.
We can show any information that we imagine, and this is the great potential of the custom field, we just need to create a query and the custom field will take care of the rest.

...