aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-webapi
diff options
context:
space:
mode:
authorPierre <pierre.guillot@sonarsource.com>2023-03-28 10:16:41 +0200
committersonartech <sonartech@sonarsource.com>2023-04-27 20:03:01 +0000
commit4114d4103e050e6213c2b514773e22d4e4a00bb2 (patch)
tree5fd582004ad0394e86a1032608a4a276144b911f /server/sonar-webserver-webapi
parent3758946e528a5234c5ab9aede8a9206fa161da0a (diff)
downloadsonarqube-4114d4103e050e6213c2b514773e22d4e4a00bb2.tar.gz
sonarqube-4114d4103e050e6213c2b514773e22d4e4a00bb2.zip
SONAR-18872 improve total ncloc computation9.9.1.69595
Diffstat (limited to 'server/sonar-webserver-webapi')
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/MarketplaceAction.java6
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/MarketplaceActionTest.java7
2 files changed, 3 insertions, 10 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/MarketplaceAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/MarketplaceAction.java
index 7c4f7b3b8bb..918f8a49b47 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/MarketplaceAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/MarketplaceAction.java
@@ -25,7 +25,6 @@ import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
-import org.sonar.db.measure.SumNclocDbQuery;
import org.sonar.server.user.UserSession;
import org.sonarqube.ws.Navigation;
@@ -68,10 +67,7 @@ public class MarketplaceAction implements NavigationWsAction {
private long computeNcloc() {
try (DbSession dbSession = dbClient.openSession(false)) {
- SumNclocDbQuery query = SumNclocDbQuery.builder()
- .setOnlyPrivateProjects(false)
- .build();
- return dbClient.liveMeasureDao().sumNclocOfBiggestBranch(dbSession, query);
+ return dbClient.projectDao().getNclocSum(dbSession);
}
}
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/MarketplaceActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/MarketplaceActionTest.java
index 7bfb5aa12aa..31b23e94ab4 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/MarketplaceActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/MarketplaceActionTest.java
@@ -28,7 +28,6 @@ import org.sonar.api.server.ws.WebService;
import org.sonar.db.DbClient;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
-import org.sonar.db.metric.MetricDto;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.UnauthorizedException;
import org.sonar.server.tester.UserSessionRule;
@@ -40,8 +39,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.sonar.api.measures.CoreMetrics.NCLOC_KEY;
-import static org.sonar.api.measures.Metric.ValueType.INT;
import static org.sonar.test.JsonAssert.assertJson;
@RunWith(DataProviderRunner.class)
@@ -120,7 +117,7 @@ public class MarketplaceActionTest {
private void setNcloc(double ncloc) {
ComponentDto project = db.components().insertPublicProject();
- MetricDto nclocMetric = db.measures().insertMetric(m -> m.setValueType(INT.toString()).setKey(NCLOC_KEY));
- db.measures().insertLiveMeasure(project, nclocMetric, m -> m.setValue(ncloc));
+ db.getDbClient().projectDao().updateNcloc(db.getSession(), project.uuid(), (long) ncloc);
+ db.commit();
}
}