Get all the issues which are Closed in last 24hrs

Hi Team,
I am using web api for filtering issues: api/issues/search
I have looked at the documentation for the same, but could not find any parameter which is on closedDate.
Is there way to pull the issues which have been closed (resolution=FIXED/REMOVED) in last 24hrs?

Thanks,
Pavan

Hi @Pavan_kumar_Nimmagad ,

To filter issues based on their closed date using the SonarQube API, you’re correct that the /api/issues/search endpoint does not have a direct parameter for filtering by closed date (closedDate). However, you can achieve your goal by leveraging the available filters and some post-processing on the client side.

Steps to Filter Closed Issues in the Last 24 Hours

  1. Fetch Issues with Resolutions: You can filter issues that have been resolved with the resolution parameter. For your case, you would be looking for issues with resolutions like FIXED or REMOVED.Example API call:
GET /api/issues/search?resolved=true&resolutions=FIXED,REMOVED
  1. Fetch the Issues: This will return all issues that have been resolved (closed) at any point in time. You will receive a JSON response containing the issues.
  2. Post-Process to Filter by Closed Date: Since the API doesn’t provide a closedDate parameter, you will need to filter the results based on the creationDate or updateDate (if available) on the client side.You can compare these dates to the current time and filter out the issues that were closed in the last 24 hours.

Thank you @Bachri_Abdel
I have planned to use the below API.
api/issues/search?severities=BLOCKER,CRITICAL&resolutions=FIXED,REMOVED,WONTFIX,FALSE-POSITIVE&resolved=true

But noticed that some issues, have “closeDate” attribute available and some do not. But updateDate is always available.
If resolution is FALSE-POSITIVE/WONTFIX the closeDate is not available
if resolution is FIXED/REMOVED the closeDate is available. In this case I noticed that closeDate=updateDate.

So can we use updateDate alone? as updating/editing/tagging a resolved issue not possible.
And there shall be updateDate always available as I am filtering the resolved issues only. Correct me, I am missing something here.
I might need to filter updateDate > currenttime -24 hours.

@Pavan_kumar_Nimmagad,

Thank you for your positive feedback! You are correct, the updateDate attribute should be sufficient for your needs, especially since you are filtering only resolved issues. Given that closeDate is not always available and updateDate is always present, this simplifies your filtering logic.

Your idea to filter with updateDate > currenttime - 24 hours also seems relevant, particularly if you want to focus on recent resolutions. By using updateDate, you ensure that you capture all modifications made to resolved issues.

If you have any more questions or need further assistance, feel free to ask! Great job on your analysis!

Something else you can consider adding is sorting the results of GET api/issues/search by CLOSE_DATE using s=CLOSE_DATE&asc=false, or UPDATE_DATE if that’s what you’ve decided to use.

1 Like

Thank you @Bachri_Abdel .
I have come-up with below api, which will sort issues by updateDate descending order and as I am filtering the resolved issues only, it is definite that updateDate will be available. I will make repeated calls with ps and p (to fetch all issues) till I get a issue with updateDate more that 24hrs ago.

Hoping the updatedate in this case will be last action taken on issue. And the action will be resolving it = (resolution=fixed, false-positive, wontfix, removed).

api/issues/search?severities=BLOCKER,CRITICAL&resolutions=FIXED,REMOVED,WONTFIX,FALSE-POSITIVE&resolved=true&s=UPDATE_DATE&asc=no&ps=500

1 Like

Thank you @Bachri_Abdel and @Colin. I will go ahead with sort on updateDate, hope no changes/updates will be allowed on closed (resolution in (FIXED,FALSE-POSITIVE,FIXED,REMOVED)) issue.

May be using 2 different queries will give more accurate data. As commenting on a closed/resolved issues is allowed, which will change the updateDate to commented date.

The below one for wontfix, falsepositive and sort on updatedate as they don;t have closeDate
api/issues/search?severities=BLOCKER,CRITICAL&resolutions=WONTFIX,FALSE-POSITIVE&resolved=true&s=UPDATE_DATE&asc=no&ps=500

The below one for fixed, removed and sort on closeDate, as they do have closeDate attribute.
/api/issues/search?severities=BLOCKER,CRITICAL&resolutions=WONTFIX,FALSE-POSITIVE&resolved=true&s=CLOSE_DATE&asc=no&ps=500

@Colin @Bachri_Abdel I have noticed one thing.
While pulling the issues using the API, the issues with resolution fixed/removed are not returning line attribute. Is this expected?
I tried using the additionalFields=_all as well.

Hi @Pavan_kumar_Nimmagad,
I think that certain properties may only be available for specific issue states or types. As the lines of code affected by the issue may not be directly relevant post-resolution, they may not be included in the API response.

Thank you @Bachri_Abdel