How to get Start and end Date of applied new code period

Hi

Problem:

  • I’am having many sonar projects in self hosted sonar server.
  • I could able to get what setting applied for new code period using API (api/new_code_periods/show?project=name).
  • But I want to get exact start and end date of this calculated new code metrics. Is it possible ?

Example scenario
Say new code setting is like below

{
“projectKey”: “projectxxx”,
“type”: “NUMBER_OF_DAYS”,
“value”: “180”,
“inherited”: true
}

  1. some projects, started recently(less than new code period already set)
  2. some are started long ago
    For case(1), I could not get the metrics for whole 180 days. In that situation, I will be better to provide new code period start date when hitting some API’s

Hey there.

GET api/components/show will return a precise start date (leakPeriodDate), and you could consider the analysisDate to be the end date.

{
    "component": {
        "key": "AYvOIyNU-JQvdKIPB6Ig",
        "name": "@sonarsource/test-project",
        "description": "test project",
        "qualifier": "TRK",
        "analysisDate": "2024-11-08T13:03:14+0000",
        "tags": [],
        "visibility": "public",
        "leakPeriodDate": "2024-10-09T13:05:29+0000",
        "version": "0.10.0",
        "needIssueSync": false
    },
    "ancestors": []
}
1 Like

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