Troubles trying to compare last 2 report with the web-api

Hello everyone,

I’m having troubles trying to compare the last two analyses of a project, I’m using the SonarQube web-api to achieve it. I did a first version which is not working everyday. Actually on my projects, analyses are triggered every day except for the week end. So I’m trying to compare friday’s report with thursday for exemple or monday with friday (taking week-end in count).

For now I’m calling this to get my measures :

variable is a date I’m getting by getting the actual date minus 10 days (not that clean).

After getting my measures I’m looking if there is at least two results and if it is then I just substract the first two to get a value (for exemple -10 code smells).

Then a mail is sent with all the information.

Maybe someone know a better way to do it (maybe with another api call) ?

I’m using SonarQube 6.7.2.

Thank you for your time and your help.

Hi Theo,

(Sorry about the accent mark - AmE keyboard. :slightly_frowning_face:)

Welcome to the community!

You’ve asked for a better way to go about this. Nothing springs to mind, but perhaps if you can share the underlying goal?

Also, it’s incumbent upon me to point out that 6.7.2 is past EOL. The current version is 8.4.1 and the current LTS is 7.9.4. You should upgrade at your earliest convenience.


Hey Ann !

Thank you for answering and welcoming me !

Actually what I want to do is to get the last analysis of the actual day and of the day before to compare them (to see for example if some code smells have been removed) every day. I’m getting the informations and I send a mail everyday to every dev of the team :slight_smile: .
The point is that I am having trouble the get the last analysis of a given day. :confused:

edit : I cannot really updrade to the latest version because it is a company strategy

Thank you in advance !

Hi Theo,

If you’re looking for raw counts, I guess you can use api/measures/search_history but it’s not clear to me why you’d want to send a notification about how many issues were closed.

Instead, we believe you should be focusing on keeping new code clean.


Hi Ann,

Actually we are using the api/measures/search_history to get our values but what I’m having trouble with is having the last analysis of a given day, for exemple the 2020/04/12 I have 5 reports, I want to get the last one of this day.

We actually focus on keeping new code clean but we also dedicate time to clean the more historical code of our applications and comparing the amount of issues we close between two given days helps the team to see the progression.


Hi Theo,

You can provide a datetime to the measures history search. And it looks like the results include datetimes. It seems like you would just check the returned values to find the newest one…?

Also, I should point out that unless you’ve tuned the housekeeping, you’ll automatically be whittled down to one analysis per day so if you really need this, then you need to pull your data quickly.