Hi,
I am trying to build a sql query (postgres) that will return the average time issues spent in status X given a timefrime (for instance in current month).
Has anyone tried this?
Thanks in advance.
I found was I was looking for here:
https://answers.atlassian.com/questions/66047
After some minor changes for POSTGRES it shows the same info you get in the Transition tabs for the issue, i.e., Time in Status. Then I had to average it over all issues for each state.
Hi Adolfo,
I have tried this logic, but not from DB, I tried getting data from JIRA server by JIRA REST Java Client on JIRA has jql you can use it.
Hi, can you share the settings you made to work in postgree? Thank you very much in advance.
For those looking for the answer in SQL, here it is:
WITH statusHistory AS(selectjiraissue.ID, changeitem.OLDSTRING OldStatus, changeitem.NEWSTRING NewStatus, changegroup.CREATED Executed,DATEDIFF(minute, changegroup.CREATED, Lead(changegroup.CREATED) OVER (Partition By jiraissue.ID ORDER BY changegroup.CREATED)) MinutesInStatus,ROW_NUMBER() OVER (Partition By jiraissue.ID order by changegroup.CREATED) StatusOrderfrom changeitem (nolock)inner join changegroup (nolock) on changeitem.groupid = changegroup.idinner join jiraissue (nolock) on jiraissue.id = changegroup.issueidwherechangeitem.field ='status')
select ID, OldStatus, NewStatus, Executed, ISNULL(MinutesInStatus, DATEDIFF(minute, Executed, GETDATE())) MinutesInStatus, StatusOrderfrom statusHistory
For those looking for postgres query, This will give you Time in status
WITH statusHistory AS(selectjiraissue.ID, p.pname, p.pkey, jiraissue.issuenum, jiraissue.priority, pri.pname as priorityname, c.cname as componentname, pv.id as fixversionId, pv.vname as fixversion, jiraissue.created as issueCreated, jiraissue.resolutiondate, changeitem.OLDSTRING OldStatus, changeitem.NEWSTRING NewStatus, changegroup.CREATED Executed,changegroup.CREATED - lag(changegroup.CREATED) over (PARTITION BY jiraissue.ID order by changegroup.CREATED) as MinutesInStatus,ROW_NUMBER() OVER (Partition By jiraissue.ID order by changegroup.CREATED) StatusOrderfrom changeiteminner join changegroup on changeitem.groupid = changegroup.idinner join jiraissue on jiraissue.id = changegroup.issueidinner join project p on jiraissue.project = p.idinner join nodeassociation na on na.SOURCE_NODE_ID = jiraissue.IDinner join projectversion pv on pv.id = na.SINK_NODE_IDjoin priority pri on pri.id = jiraissue.priorityinner join component c on na.sink_node_id = c.idwherechangeitem.field ='status' AND changeitem.FIELDTYPE='jira' And pkey = 'HM')
Select * From statusHistory
It looks like you're new here. Sign in or register to get started.