princenyeche / jiraone

A REST API Implementation to Jira Cloud APIs for creating reports and for performing other Jira queries.
https://jiraone.readthedocs.io
MIT License
25 stars 11 forks source link

Issue with Retrieving Full Project History Using Jiraone REST API #134

Open aamiryousuf opened 7 months ago

aamiryousuf commented 7 months ago

Hello,

I am currently utilizing the Jiraone REST API for extracting project history, which has been incredibly useful. However, I'm encountering a limitation with projects that contain extensive data. Specifically, I'm only able to retrieve history data up until last year, and not all details are being pulled.

Below is the Python script I'm using. I'm exploring whether there's a way to fetch the complete history, or, if data volume is an issue, to selectively specify certain fields within the history to retrieve all relevant changes. Alternatively, could I implement a date range to segment the output into manageable chunks? Another possibility I'm considering is whether there's an alternative to using PROJECT.change_log for this purpose.

I appreciate any guidance you can provide, as I'm relatively new to both Jira and Python.


from jiraone import LOGIN, PROJECT

# User credentials and Jira instance URL
user = "my_email"
password = "my_Token"
link = "My_DC_URL"

# Log into the Jira instance
LOGIN.api = False
LOGIN(user=user, password=password, url=link)

# Main execution
if __name__ == '__main__':
    # the output of the file would be relative to the directory where this python file is executed
    jql = "issuekey in (ID-54145)"  # A valid JQL query
    PROJECT.change_log(jql=jql)

Thanks for your assistance,

Aamir
princenyeche commented 6 months ago

Hey @aamiryousuf

If you're not getting all the data, it depends on what level of access you have to the project. The method uses JQL, so if no errors are being returned to you, it is safe to assume that, the data gotten is what it could fetch from the search or the entire data contained available to your permission. The change_log method will pull out the history synchronously from your Jira site but it can have performance issues if the data being pulled is a lot. You might want to try the asynchronous method async_change_log to see if there's any difference in the data pulled by both.

# import statement
PROJECT.async_change_log(
               jql, folder="TEST", file="sample.csv", flush=20
            )

This method allows multiple extraction quickly and should extract everything. When using JQL, you can specify a date range as that's JQL's ability to filter your search criteria. I suggest using that if you want to limit the search range. If both are the same, then you might want to check how many issues are actually returned based on your JQL or if those issues actually have historical content.