Jira version: 5.2.2
database: mysql
I would like to check user activity to see how long a user is taking to perform a certain task. Based on a query from JRA-12825, i perform this query(not quite optimized yet)
SELECT c.pname, b.`CALLER`, MIN(TIMEDIFF(b.`FINISH_DATE`, b.`START_DATE`)) as minTime, MAX(TIMEDIFF(b.`FINISH_DATE`, b.`START_DATE`)) as maxTime, SEC_TO_TIME(AVG(TIME_TO_SEC(TIMEDIFF(b.`FINISH_DATE`, b.`START_DATE`)))) as average, SEC_TO_TIME(STDDEV(TIME_TO_SEC(TIMEDIFF(b.`FINISH_DATE`, b.`START_DATE`)))) as stdDev, COUNT(1) as cnt FROM os_historystep b, jiraissue a, issuestatus c where (a.`ID` = b.`ENTRY_ID`) and (a.`PROJECT` = 10000) and b.STEP_ID = c.sequence and b.ACTION_ID != 0 group by pname, CALLER
I assume that Jira is automatically inserting a record when b.ACTION_ID = 0, so I ignore those records.
Problem--This query does not take into account when a user reassigns a task to another user. For instance, user Amy is assigned a task and reassigns the task to user Bob(without changing the status of the task). User Bob eventually closes the task, but user Amy is charged with the entire time until the status of the task changes.
Question--Is there a way to remove the tasks from the query that have been reassigned to someone else and just select results that have not been handled by multiple users? or is there a better way?
If you read the issue history instead, you'd have access to all the changes of assignee in the same place as all the status changes. I suspect that would make it easier in general, but if you stick with os_workflow for the status information, you still need to read changeitem and changegroup for the changes of assignee.
Thank you for the guidance. I decided to stick with the original and filter out issues with multiple assignees between workflow transitions. This query is, however, much more intensive than the original query, so it is probably best to use the first query as a close approximation during normal operations.
SELECT c.pname, b.`CALLER`, MIN(TIMEDIFF(b.`FINISH_DATE`, b.`START_DATE`)) as minTime, MAX(TIMEDIFF(b.`FINISH_DATE`, b.`START_DATE`)) as maxTime, SEC_TO_TIME(AVG(TIME_TO_SEC(TIMEDIFF(b.`FINISH_DATE`, b.`START_DATE`)))) as average, SEC_TO_TIME(STDDEV(TIME_TO_SEC(TIMEDIFF(b.`FINISH_DATE`, b.`START_DATE`)))) as stdDev, COUNT(1) as cnt FROM os_historystep b, jiraissue a, issuestatus c where (a.`ID` = b.`ENTRY_ID`) and (a.`PROJECT` = 10000) and b.STEP_ID = c.sequence and b.ACTION_ID != 0 and a.ID not in (SELECT distinct cg.issueid FROM changeitem ci, changegroup cg where ci.groupid = cg.id and ci.field = "assignee" and (ci.field, cg.issueid) = (SELECT ci2.field, cg2.issueid FROM changeitem ci2, changegroup cg2 where ci2.groupid = cg2.id and cg2.issueid >= cg.issueid and ci2.groupid >= ci.groupid and ci2.field >= ci.field order by cg2.issueid, ci2.groupid, ci2.field limit 1 offset 1 )order by cg.issueid, ci.groupid, ci.field ) group by pname, CALLER
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.