Api/measures/search_history returns only date history

web_api

(Jung Hyun Kwon) #1

Hello.

I want to get complexity value of a file over commits. I used api/measures/search_history api to do that. However, what I received is as follows and it just showed analysis date of each commit. I looked into the documentation, but I could not find why the complexity value is not provided.

{
    "paging": {
        "pageIndex": 1,
        "pageSize": 100,
        "total": 843
    },
    "measures": [
        {
            "metric": "complexity",
            "history": [
                {
                    "date": "2018-06-22T01:21:34+0200"
                },
                {
                    "date": "2018-06-22T02:11:39+0200"
                },
...
}

(Julien Lancelot) #2

Hi,

Indeed, this web service will return all analysis date, even when the metric is not computed.
In your case, it means that when the metric was not computed for the returned analysis, but it may have been computed for others analysis.

Regards.


(Jung Hyun Kwon) #3

Thank you for answer.

I would like to know when the metric is computed.
Actually, I could not see any complexity value across all analysis date. This is weird because the file is JavaScript file and it was modified often (34 times).
I thought that SonarCloud calculates complexity of each changed file every analysis so that complexity of a project can be provided.


(Julien Lancelot) #4

Could you please check if the complexity is computed on last analysis ?


(Jung Hyun Kwon) #5

Complexity of a project is computed, and I can see its history. However, I cannot see complexity history of a file in the project. I can see only current complexity of the file.
Is there way to see complexity history of a file in the project? api/measures/search_history API does not seem to work for a file. It shows only date history.


(Julien Lancelot) #6

Ok now I understand => there’s no bug in the WS, history on files are not kept as it would increase too much the size of the database (see https://docs.sonarqube.org/display/SONAR/Housekeeping for more details on this).