Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

GetChangeLogAsync() does not return all changelogs...how do I fetch all?

P_ September 23, 2019

Hi,

while working on an app that connects to our JIRA Server using Atlassian SDK, I noticed a strange thing - when calling GetChangeLogsAsync, I do not get all the change logs, just some of the latests (or it seems so). This seems to be especially true for worklog related items storing changes of timespent and timeestimate, which is what I am interested in.

I need to track how Remaining Time evolves over time and for that I need to track it via records in change logs. However for older issues there are NO change logs with this information returned, even though the value was changed. When I do exactly the same action with a new issue, I can see and fetch these change logs just fine.

2 answers

0 votes
P_ September 23, 2019

Answered by mistake..cannot delete

0 votes
fran garcia gomera
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 23, 2019

GetChangeLogsAsync is using an API call 

rest/api/2/issue/{issuekey}?fields=created&expand=changelog

does that works on those issues where yoou can't find the log?

 

also, you can try to get the values rigtht from the DB:

SELECT p.pname, p.pkey, i.issuenum, cg.ID, cg.issueid, au.lower_user_name, cg.AUTHOR, cg.CREATED, ci.FIELDTYPE, ci.FIELD, ci.OLDVALUE, ci.OLDSTRING, ci.NEWVALUE, ci.NEWSTRING
FROM changegroup cg
inner join jiraissue i on cg.issueid = i.id
inner join project p on i.project = p.id
inner join changeitem ci on ci.groupid = cg.id
inner join app_user au on cg.author = au.user_key
WHERE cg.issueid=(select id from jiraissue where issuenum = 24 and project in (select id from project where pname = 'Peticiones'))
order by 1,3,4; 
P_ September 23, 2019

I cannot access the DB, I work for a big corporation..

 

Anyway - I do not believe the API call you mentioned is used there because when I execute it in the browser, the data I am looking for are there. When I use this GetChangeLogsAsync function, they are missing, not returned it seems. Why the heck would be "older" records not returned? And what is "older"? It is quite frustrating, to be honest.

fran garcia gomera
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 23, 2019

Doen't seems to make sense.

This is the method definition from 

/Atlassian.Jira/Remote/IssueService.cs

       public async Task<IEnumerable<IssueChangeLog>> GetChangeLogsAsync(string issueKey, CancellationToken token = default(CancellationToken))
        {
            var resourceUrl = String.Format("rest/api/2/issue/{0}?fields=created&expand=changelog", issueKey);
            var serializerSettings = _jira.RestClient.Settings.JsonSerializerSettings;
            var response = await _jira.RestClient.ExecuteRequestAsync(Method.GET, resourceUrl, null, token).ConfigureAwait(false);
            var result = Enumerable.Empty<IssueChangeLog>();
            var changeLogs = response["changelog"];
            if (changeLogs != null)
            {
                var histories = changeLogs["histories"];
                if (histories != null)
                {
                    result = histories.Select(history => JsonConvert.DeserializeObject<IssueChangeLog>(history.ToString(), serializerSettings));
                }
            }

            return result;
        }
P_ September 23, 2019

You see, I get ALL logs related to changes of STATUS, RESOLUTION etc. But when it comes to time tracking, I get only "recent" logs. For example, I am getting two logs I created today, but it does not return the one I created on Friday. All are the same - logging work.

 

EDIT: Funny thing, in the JSON I can see "timespent" and "timeestimate" data with correct values, but they are NOT shown in the resulting object in C#..

fran garcia gomera
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 23, 2019

logging work is a little tricky, Jira stores them in a different table in the DB. Don't know right now if it saves the recent ones with some purpose. Let me check it

P_ September 23, 2019

The problem is - if the time tracking change is new, it IS returned as a part of the changelog - I am getting "timespent" from and to. And it is also shown in the JIRA UI.

But for older issues it seems it is neither returned nor shown in the UI. 

fran garcia gomera
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 23, 2019

I have checked the DB, both tables save the info. worklog and changeitem (joined with changegroup)

I can't figure out no reason why you lost that kind of logs

P_ September 23, 2019

It must be some server feature that prevents older time-related logs from returning?

 

You can try it yourself:

  1. Find a sub-task to which time was logged at leat 3 days ago
  2. Return its changelog - no "worklog" items will be found in the changelog history
  3. Now log time to that issue
  4. Return its changelog - you will see a fresh "worklog" item in the changelog history
fran garcia gomera
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 23, 2019

The problem is - if the time tracking change is new, it IS returned as a part of the changelog - I am getting "timespent" from and to. And it is also shown in the JIRA UI.

But for older issues it seems it is neither returned nor shown in the UI. 

 

and do they appear when you send the rest API request?

P_ September 23, 2019

Yes, if they are new, they correctly appear in both the UI and API calls. Older ones are not visible in the UI and also are not returned..

P_ September 23, 2019

I noticed that the following record is only visible for recent changes - no older issues have this visible in their activity logs:

 

image.png

And this is obviously related - once this is not shown anymore in the UI, it is also not returned by the API.

Suggest an answer

Log in or Sign up to answer