Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Fetch history changelog within certain range

Ventsislav
Contributor
July 10, 2020

Hi,

I am trying to pull issue history only within certain range.

Currently using jira-python package, but if this is possible to do with requests and REST API it would be acceptable.

Currently I have the following:

updated_issues = auth_jira.search_issues(f'project in {projects} and updated >= "-1h"', expand=['changelog'])

The above would fetch all issues that had been updated in the past 1 hour.

for issue in updated_issues:

    for history in issue.changelog.histories:

        for item in history.items:

            if item.field == 'status':

                print('status')

                print(f'Date: {history.created}; From: {item.fromString}; To: {item.toString}')

However, the problem is that changelog.histories contains all changelogs for the particular issue as opposed to just the changes in the past hour.

Is there a filter I can apply? Alternatively a JQL query to target the changelogs directly would also probably work.

Any help would be highly appreciated!

3 answers

1 vote
Deleted user February 8, 2021

I would also like to get changelog.histories  from specified time range. Any updates/workarounds for this?

0 votes
Prince Nyeche
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 12, 2020

Hi @Ventsislav 

I believe you will need to drill down with the output, If i'm not mistaken, the changelog history of an issue contains a created field to show the datetime in which the history existed. you can add more conditions to your "if" expression using timedelta class from datetime module. Probably create a function to parse out the datetime correctly into a timedelta from the created field and compare it again to a datetime you'll set, so the output will be only the time period between both dates.

Also, I don't think there's a filter for JQL changelog on an issue's history.

0 votes
Earl McCutcheon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 24, 2020

Hello @Ventsislav ,

The issue history items pulled from the API are all going to come back as the full history of the issue as a single JSON element and will not have individual values that can be pulled from the API itself using expand options like you could for pulling individual field data as described here:

To pull out specific data points from the issue history you would want to look at scripting something locally on the JSON data that was returned to parse out the data points you are looking for.

I am thinking something like a JSON.parse() could help you out here, which turns data elements in the JSON package into a JavaScript object that can be called for additional breakdown in your script, some examples can be seen here:

Regards,
Earl

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events