SQL How can I find who opened a Sprint?

Bernd Prager May 18, 2017

Can somebody help me to find the relation in the database on who opened a particular Sprint?

Thank you!

4 answers

1 accepted

1 vote
Answer accepted
Leonard Chew
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2019

Jira Version: 7.7.1

The data of the sprint creation is stored in the table userhistoryitem, but it is not 100% reliable, as it can be overwritten or be deleted.

userhistoryitem only contains the sprint name at creation time, but not the current sprint name, and the timestamp can be overwritten as stated above.
Usually you will rename the sprint right after creation, so you want to select on the current sprint name.

Here is the database SQL for an oracle database:

select (TO_DATE('1970-01-01','YYYY-MM-DD') + lastviewed / 86400000) changed_timestamp, 
uh.username created_by,
uh.data original_name,
s.name current_sprint_name
from ao_60db71_sprint s
left join userhistoryitem uh
on (uh.entitytype='Sprint' and s.id = uh.entityid)
where s.name like 'MYCURRENTSPRINTNAME'
order by changed_timestamp;

 

Notes

  • replace MYCURRENTSPRINTNAME with your sprint name
  • lastviewed is stored as milliseconds after 01.01.1970, so it needs to be transformed to into a readable format.
  • userhistorydata is tricky. It only stores one record per user and sprint. As long as the creator is the only person editing the sprint name, the changed_timestamp will remain the creation date.
    If, however, a different user (user X) edits the Sprint Name and the creator edits the sprint name again, then the changed_timestamp of the creator will not be the creation date anymore. (it will be the timestamp where he edited the name after user X had edited the name before)
  • userhistorydata gets purged periodically, so this query will only work for a few weeks after sprint creation
  • summary: the first record of the SQL will most probably be the creator with the creation timestamp, however not 100%.
Dmitrii Aldunin April 29, 2021

Could someone translate this query to MS SQL? MS SQL cannot find some objects like 

ao_60db71_sprint
Like YY哥 likes this
Leonard Chew
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 8, 2022

Tables starting with ao_xxxx_ are Tables that are created by a Plugin.
xxxx is somewhat the id of the Plugin.

The sprint table is delivered by the "plugin" Jira Software (it is not part of Jira Core).

If you dont find a table by the name ao_60db71_sprint, look for another table with the name ao_xxxx_sprint.

0 votes
Bernd Prager May 18, 2017

Can I assume that the first entry in the "userhistoryitem" for the sprint's "rapid_view" represents the creator?

/* Find Sprint creator */
DECLARE @SPRINT BIGINT
--
SELECT @SPRINT = 5416
--
SELECT TOP 1 UH.ID, SP.NAME sprintname, USERNAME creator
FROM [My_Jira].[dbo].[userhistoryitem] UH 
INNER JOIN [My_Jira].[dbo].[AO_60DB71_SPRINT] SP WITH(NOLOCK) ON UH.ENTITYID = CAST(SP.RAPID_VIEW_ID AS NVARCHAR)
WHERE SP.ID = @SPRINT;
0 votes
Anil singh May 18, 2017

As per my knowledge, Jira doesn't provide this functionality. 

 

 

0 votes
Bernd Prager May 18, 2017

I found here that (unfortunately) this info does not seem to be stored in the Jira database

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events