]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16423 - Project license API changes
authorBelen Pruvost <belen.pruvost@sonarsource.com>
Thu, 2 Jun 2022 12:23:15 +0000 (14:23 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 2 Jun 2022 20:03:18 +0000 (20:03 +0000)
server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java
server/sonar-db-dao/src/main/java/org/sonar/db/measure/LargestBranchNclocDto.java
server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml
server/sonar-db-dao/src/test/java/org/sonar/db/measure/LargestBranchNclocDtoTest.java
sonar-ws/src/main/java/org/sonarqube/ws/client/projects/ProjectsService.java

index 112752428a3f6c51c4a0b1dd62d360894fe81932..76c699ab92cb7bc0fdebe4b45efad64c310854cf 100644 (file)
@@ -76,6 +76,7 @@ import org.sonar.db.issue.NewCodeReferenceIssueDto;
 import org.sonar.db.issue.PrIssueDto;
 import org.sonar.db.mapping.ProjectMappingDto;
 import org.sonar.db.mapping.ProjectMappingsMapper;
+import org.sonar.db.measure.LargestBranchNclocDto;
 import org.sonar.db.measure.LiveMeasureMapper;
 import org.sonar.db.measure.MeasureDto;
 import org.sonar.db.measure.MeasureMapper;
@@ -201,6 +202,7 @@ public class MyBatis {
     confBuilder.loadAlias("Issue", IssueDto.class);
     confBuilder.loadAlias("NewCodeReferenceIssue", NewCodeReferenceIssueDto.class);
     confBuilder.loadAlias("Measure", MeasureDto.class);
+    confBuilder.loadAlias("LargestBranchNclocDto", LargestBranchNclocDto.class);
     confBuilder.loadAlias("NotificationQueue", NotificationQueueDto.class);
     confBuilder.loadAlias("PermissionTemplateCharacteristic", PermissionTemplateCharacteristicDto.class);
     confBuilder.loadAlias("PermissionTemplateGroup", PermissionTemplateGroupDto.class);
index 579fe18f34499619f8007bc4aa8d86dddecec18e..a6d41c798b0bb9c9cd84d494b0b1afb21de7e39d 100644 (file)
@@ -27,7 +27,6 @@ public class LargestBranchNclocDto {
   private long loc;
   private String branchName;
   private String branchType;
-  private long lastAnalysisDate;
 
   public String getProjectUuid() {
     return projectUuid;
@@ -82,13 +81,4 @@ public class LargestBranchNclocDto {
     this.loc = loc;
     return this;
   }
-
-  public long getLastAnalysisDate() {
-    return lastAnalysisDate;
-  }
-
-  public LargestBranchNclocDto setLastAnalysisDate(long lastAnalysisDate) {
-    this.lastAnalysisDate = lastAnalysisDate;
-    return this;
-  }
 }
index 3fe2bcd3fc5b3ec9047d60b63414c15c958b0996..3516f05dcda2f0e1ff1f24217b3f759fc841c29c 100644 (file)
     ) sumncloc
   </select>
 
-  <select id="getLargestBranchNclocPerProject" parameterType="map" resultType="org.sonar.db.measure.LargestBranchNclocDto">
+  <select id="getLargestBranchNclocPerProject" parameterType="map" resultType="LargestBranchNclocDto">
     select tie_breaker.projectUuid,
     tie_breaker.projectName,
     tie_breaker.projectKey,
     ncloc as loc,
     pb.kee as branchName,
-    pb.branch_type as branchType,
-    s.created_at as lastAnalysisDate
+    pb.branch_type as branchType
       from
         (select counter.projectUuid as projectUuid,
           counter.maxncloc ncloc,
           group by counter.projectUuid, counter.maxncloc, counter.projectName, counter.projectKey) tie_breaker
       inner join components c2 on c2.kee  = tie_breaker.component_kee
       inner join project_branches pb on c2.uuid = pb.uuid
-      inner join snapshots s on s.component_uuid = c2.uuid
-      where s.islast = ${_true}
       order by ncloc desc
   </select>
 
index e5b2f71e2fb7433732847b683d0ff5ab91116eb5..2103a769736bc53ea995149116d4da89b62940df 100644 (file)
@@ -37,7 +37,6 @@ public class LargestBranchNclocDtoTest {
     assertThat(underTest.getLoc()).isEqualTo(123L);
     assertThat(underTest.getBranchName()).isEqualTo("branchName");
     assertThat(underTest.getBranchType()).isEqualTo("branchType");
-    assertThat(underTest.getLastAnalysisDate()).isEqualTo(1L);
   }
 
   private void setUnderTest() {
@@ -47,8 +46,7 @@ public class LargestBranchNclocDtoTest {
       .setProjectKey("projectKey")
       .setLoc(123L)
       .setBranchName("branchName")
-      .setBranchType("branchType")
-      .setLastAnalysisDate(1L);
+      .setBranchType("branchType");
   }
 
 }
index 27cc69dbb3ae0d7aa5983ee98d873a26647cba4a..90781ba4bb2fecf69abd414e8b5e8447786b7d69 100644 (file)
@@ -22,7 +22,6 @@ package org.sonarqube.ws.client.projects;
 import java.util.stream.Collectors;
 import javax.annotation.Generated;
 import org.sonarqube.ws.MediaTypes;
-import org.sonarqube.ws.Projects;
 import org.sonarqube.ws.Projects.CreateWsResponse;
 import org.sonarqube.ws.Projects.SearchMyProjectsWsResponse;
 import org.sonarqube.ws.Projects.SearchWsResponse;
@@ -101,10 +100,10 @@ public class ProjectsService extends BaseService {
    * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/projects/license_usage">Further information about this action online (including a response example)</a>
    * @since 9.4
    */
-  public String licenseUsage() {
+  public WsResponse licenseUsage() {
     GetRequest getRequest = new GetRequest(path("license_usage"))
-      .setMediaType(MediaTypes.CSV);
-    return call(getRequest).content();
+      .setMediaType(MediaTypes.JSON);
+    return call(getRequest);
   }
 
   /**