What is the TEMPO database table relationship between worklogs, Issues, and billing accounts?

Tim Baxter August 23, 2013

I am trying to write an SQL query to collect various time-logged statistics. Time spent is stored in the Worklog table. It appears to me that the WORKLOG table has a key into the Jiraissue table via the issueid. The Jiraissue table has valuable information but I cannot see the link or location to where the Billing Account codes are stored. I have defined 4 accounts and linked projects and issues to these accounts. What I want to do is group (in SQL) by account. Can anyone help?

8 answers

1 accepted

1 vote
Answer accepted
Tim Baxter September 2, 2013

Oops. Prematurely sent this post. What I meant to ask is Tempo would fix the HTML withing XML problem or if they would give an option to bypass the Worklog Description?

Tim

Bjarni Thorbjornsson
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.
September 3, 2013

Hi Tim,

Please create an issue in the Tempo tracker: https://tempoplugin.jira.com/browse/TT

Best regards,

-Bjarni

Iman Modarres Gharavi June 20, 2018

I write this query to fetch my issue with account key. you have to amend AO_C3C6E8_ACCOUNT_V1  as it has diffrent value based on your installation and also custom field value of 10100   with is associated with your tempo account based on your installation.

 

SELECT
AO_C3C6E8_ACCOUNT_V1.`KEY` as AccountKey,
concat(project.pkey , '-' , jiraissue.issuenum) AS Issue_Key ,
jiraissue.id,
jiraissue.pkey,
project.pname AS project,
jiraissue.summary,
issuetype.pname AS issuetype,
issuestatus.pname AS status,
resolution.pname as resolution,
jiraissue.assignee,
jiraissue.reporter,
jiraissue.created,
jiraissue.UPDATED,
jiraissue.resolutiondate,
jiraissue.duedate,
jiraissue.description,
jiraissue.TimeSpent/60/60 as TimeSpentHour,
issueComponent.components,
(select cfv1.textvalue from customfieldvalue cfv1 where cfv1.issue = jiraissue.id and cfv1.customfield = 10100) as customfield1
-- (select cfv2.numbervalue from customfieldvalue cfv2 where cfv2.issue = jiraissue.id and cfv2.customfield = 10101)as customfield2
FROM jiraissue join project on jiraissue.project=project.ID
join issuetype on jiraissue.issuetype=issuetype.ID
join issuestatus on jiraissue.issuestatus=issuestatus.ID
left outer join ( select SOURCE_NODE_ID,GROUP_CONCAT(cname SEPARATOR ', ') components from component
inner join nodeassociation on component.id=nodeassociation.SINK_NODE_ID
where ASSOCIATION_TYPE='IssueComponent'
group by SOURCE_NODE_ID) issueComponent
on issueComponent.SOURCE_NODE_ID=jiraissue.id
left outer join resolution on jiraissue.resolution=resolution.ID
left outer join customfieldvalue cfv1 on cfv1.customfield = 10100 and cfv1.ISSUE=jiraissue.id
left outer join AO_C3C6E8_ACCOUNT_V1 on AO_C3C6E8_ACCOUNT_V1.id=cfv1.NUMBERVALUE
where jiraissue.UPDATED >'2018-05-20'
limit 10

1 vote
Eric Grubaugh May 16, 2015

This thread is a bit old, but I just had to work through modifying all of our Tempo Account keys and the worklogs associated with them. I've written about that here: https://medium.com/atlassian-adventures/changing-account-keys-in-jira-tempo-accounts-b3eb5a2d7de3

0 votes
Bjarni Thorbjornsson
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.
June 8, 2015

Thanks Eric, The attributes and the accounts are indeed cached and that is why you didn't see the changes in the UI immediately. (DB changes like these should never be done on a live system to avoid cache corruption.) Thanks for sharing and glad it worked for you :) -Bjarni

0 votes
Tim Baxter September 2, 2013

Bjarni,

Is there a way to communicate to the Tempo folks to ask them for a code enhancement to fix web api? It would be nice if they fixed

0 votes
Tim Baxter August 29, 2013

Bjarni,

Thank you for your quick reply.

For some reason we do not ave any propertyentry.Entity_Name with a value 'Tempo.Worklog'. We do have 'Tempo.Billing or 'Tempo.Config'.

Also, we have been trying to use the servlet but are receiving errors because our users are including HTML data in the Worklog Description. The error is something caused by HTML inside XML.

Is there a way we can prevent the Servlet from returning the Worklog Description?

Sincerely,

Tim

Bjarni Thorbjornsson
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.
September 1, 2013

Hi Tim,

The Tempo worklog attributes are currently stored as 'Tempo.Worklog' entries. If you don't have those you are not using the Tempo worklog attributes for the accounts but simply the JIRA custom field and you should therefore check the JIRA SQL page that I sent you before. You have probably stumbled up on the accounts config.

I don't think you can currently skip the worklog description from the servlet export.

Hope this helps,

-Bjarni

Luis Yovera March 30, 2015

Hi Bjarni If I would like to insert some tempo worklog attributes theought database, How I can do it ? Regards, Luis Yovera

0 votes
Tim Baxter August 28, 2013

Bjarni,

This gets me closer to my objective. I did find the accounts stored in property _entry and property_string. WooHoo! Now my challeng is to find the link from the worklog. I know there may be several hops but it still illudes me.

Tim

Bjarni Thorbjornsson
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.
August 29, 2013

You join the worklog.id to the propertyentry.entity_id and the propertyentry.id to propertystring.id. Something like this:

select ps.propertyvalue 
  from propertyentry pe,
       propertystring ps,
       worklog w,
       jiraissue ji
  where ji.pkey = 'TMA-3014'
    and ji.id = w.issueid
    and w.id = pe.entity_id
    and pe.entity_name = 'Tempo.Worklog'
    and pe.property_key = 'Tempo.WorklogAttributes'
    and pe.id = ps.id

Please note that is SQL is not supported and we will change this structure in the future.

Best regards,

-Bjarni

0 votes
Tim Baxter August 25, 2013

Thank you Benedikt. I have used the servlet and it is quite useful. I do have one question though. What is the linkage from the Jiraissue table, to account code. We only have 4 billing codes. If I could even find the link it would help my cause.

Bjarni Thorbjornsson
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.
August 26, 2013

Hi Tim,

The issue account is a normal custom field and is stored in the JIRA custom field tables. I didn't find your exact query, but here are some SQL examples that you can work from: https://confluence.atlassian.com/display/JIRACOM/Example+SQL+queries+for+JIRA#ExampleSQLqueriesforJIRA-GetCustomStringFieldforanIssue%28SqlServerfunction%29

Hope this helps,

-Bjarni

P.S. If you are using the account as a worklog attribute, you need to query the property_entry and property_string tables by the worklog_id.

0 votes
Benedikt Bjarni Bogason [Tempo]
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.
August 23, 2013

Hi Tim,

The issue and worklog tables are JIRA tables.

The Tempo account data is stored in a proprietary XML format that we can change the format/layout at any time. We do not support any direct access or manipulation of the data, but we do provide a simple servlet that returns a list of the accounts, see this site for further info:

https://tempoplugin.jira.com/wiki/display/TEMPO/Tempo+Servlet+Manual#TempoServletManual-BillingKeyList

Hope this helps!

Suggest an answer

Log in or Sign up to answer