User activity from os_historystep

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?

1 answer

1 accepted

1 vote

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

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

Meet the AUG leaders of Northern Virginia

@Rachel Wright (Jira Genie), @Billy Poggi (AUG NOVA, DC), and @Dana Jansen (Confluence Queen) are just some of the folks that lead one of the world's most active Atlassian User Group (AUG)....

123 views 4 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you