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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Fetch history changelog within certain range Edited

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

0 votes

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

0 votes
Prince Nyeche Community Leader Aug 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

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

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
Community showcase
Published in Jira

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

874 views 14 20
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you