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

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

292 views 5 0
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