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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,307 views 14 20
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot