Api/measures/search_history returns only date on new_* metrics

  • sonarqube 8.9 community edition
  • api/measures/search_history returns only date on new_* metrics

all new_* metrics only shows date, no values were provided. for example:
for example new_bugs,new_code_smells,new_lines,new_security_hotspots,new_vulnerabilities

can I do a simple substract to caculate the new_xxx value?

{
    "paging": {
        "pageIndex": 1,
        "pageSize": 100,
        "total": 15
    },
    "measures": [
        {
            "metric": "ncloc",
            "history": [
                {
                    "date": "2021-07-19T20:49:24+0800",
                    "value": "503666"
                },
                {
                    "date": "2021-07-20T11:15:02+0800",
                    "value": "503666"
                },
                {
                    "date": "2021-07-21T20:27:03+0800",
                    "value": "503666"
                },
                {
                    "date": "2021-07-22T21:36:55+0800",
                    "value": "503836"
                },
                {
                    "date": "2021-07-23T20:17:29+0800",
                    "value": "357181"
                },
                {
                    "date": "2021-07-25T18:43:19+0800",
                    "value": "358063"
                },
                {
                    "date": "2021-07-26T18:13:11+0800",
                    "value": "358095"
                },
                {
                    "date": "2021-07-27T22:22:46+0800",
                    "value": "358157"
                },
                {
                    "date": "2021-07-28T20:04:57+0800",
                    "value": "358301"
                },
                {
                    "date": "2021-07-29T10:04:21+0800",
                    "value": "358260"
                },
                {
                    "date": "2021-07-29T10:56:16+0800",
                    "value": "358260"
                },
                {
                    "date": "2021-07-29T14:49:12+0800",
                    "value": "358260"
                },
                {
                    "date": "2021-07-29T15:56:09+0800",
                    "value": "358261"
                },
                {
                    "date": "2021-07-29T21:23:04+0800",
                    "value": "334121"
                },
                {
                    "date": "2021-07-29T22:05:09+0800",
                    "value": "334121"
                }
            ]
        },
        {
            "metric": "new_lines",
            "history": [
                {
                    "date": "2021-07-19T20:49:24+0800"
                },
                {
                    "date": "2021-07-20T11:15:02+0800"
                },
                {
                    "date": "2021-07-21T20:27:03+0800"
                },
                {
                    "date": "2021-07-22T21:36:55+0800"
                },
                {
                    "date": "2021-07-23T20:17:29+0800"
                },
                {
                    "date": "2021-07-25T18:43:19+0800"
                },
                {
                    "date": "2021-07-26T18:13:11+0800"
                },
                {
                    "date": "2021-07-27T22:22:46+0800"
                },
                {
                    "date": "2021-07-28T20:04:57+0800"
                },
                {
                    "date": "2021-07-29T10:04:21+0800"
                },
                {
                    "date": "2021-07-29T10:56:16+0800"
                },
                {
                    "date": "2021-07-29T14:49:12+0800"
                },
                {
                    "date": "2021-07-29T15:56:09+0800"
                },
                {
                    "date": "2021-07-29T21:23:04+0800"
                },
                {
                    "date": "2021-07-29T22:05:09+0800"
                }
            ]
        },

Hi,

Welcome to the community!

We don’t store historical values for new_* metrics because once they’re historical… they’re no longer new.

Not reliably. This would work if you only ever added code to your project. But since you likely also edit and delete lines, simple math isn’t going to give you correct values.

Could you share why you want this?

 
Ann

Hi Ann,
The new_xxx is returned through the documentation example. I consider this is a snapshot data after each scan comparing to the very first scan.
https://next.sonarqube.com/sonarqube/web_api/api/measures

What I want is to find out how many new issues、code_smells were generated in every day or commit across all the projects.

I think the data is available, I just dont know how to get it by using openapi

Hi,

Thanks for pointing out those docs. We’ll get them fixed.

Sorry, but it’s really not. You could look at all issues and make some counts by creation date, but that’s still not going to get you the number of issues opened on a given day because as issues are fixed in code, they’re cleaned out of the database.

 
:woman_shrugging:
Ann

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.