From: Alain Kermis Date: Fri, 17 Feb 2023 10:44:37 +0000 (+0100) Subject: SONAR-18472 Resolve telemetry performance issue X-Git-Tag: 10.0.0.68432~218 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7905ff733382405d64a3d08e3c33a24fb5fde94b;p=sonarqube.git SONAR-18472 Resolve telemetry performance issue Co-authored-by: Jacek Poreda --- diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java index 4823fa8cfab..54647f71c9c 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java @@ -80,7 +80,7 @@ import org.sonar.db.measure.LargestBranchNclocDto; import org.sonar.db.measure.LiveMeasureMapper; import org.sonar.db.measure.MeasureDto; import org.sonar.db.measure.MeasureMapper; -import org.sonar.db.measure.ProjectMeasureDto; +import org.sonar.db.measure.ProjectLocDistributionDto; import org.sonar.db.metric.MetricMapper; import org.sonar.db.newcodeperiod.NewCodePeriodMapper; import org.sonar.db.notification.NotificationQueueDto; @@ -223,7 +223,7 @@ public class MyBatis { confBuilder.loadAlias("ProjectAlmKeyAndProject", ProjectAlmKeyAndProject.class); confBuilder.loadAlias("PrAndBranchCountByProjectDto", PrBranchAnalyzedLanguageCountByProjectDto.class); confBuilder.loadAlias("ProjectMapping", ProjectMappingDto.class); - confBuilder.loadAlias("ProjectMeasure", ProjectMeasureDto.class); + confBuilder.loadAlias("ProjectLocDistribution", ProjectLocDistributionDto.class); confBuilder.loadAlias("PurgeableAnalysis", PurgeableAnalysisDto.class); confBuilder.loadAlias("PushEvent", PushEventDto.class); confBuilder.loadAlias("QualityGateCondition", QualityGateConditionDto.class); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java index 7e5547fc292..17441f11236 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java @@ -109,6 +109,10 @@ public class LiveMeasureDao implements Dao { return mapper(dbSession).getLargestBranchNclocPerProject(); } + public List selectLargestBranchesLocDistribution(DbSession session, String nclocUuid, String nclocDistributionUuid) { + return mapper(session).selectLargestBranchesLocDistribution(nclocUuid, nclocDistributionUuid); + } + public long countProjectsHavingMeasure(DbSession dbSession, String metric) { return mapper(dbSession).countProjectsHavingMeasure(metric); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java index 9d2765d89e3..5891b136fd7 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureMapper.java @@ -64,6 +64,8 @@ public interface LiveMeasureMapper { List getLargestBranchNclocPerProject(); + List selectLargestBranchesLocDistribution(@Param("nclocUuid") String nclocUuid, @Param("nclocDistributionUuid") String nclocDistributionUuid); + Long countProjectsHavingMeasure( @Param("metric") String metric); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureDao.java index df552e3aeb6..2c9fb0a195e 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureDao.java @@ -76,8 +76,4 @@ public class MeasureDao implements Dao { return session.getMapper(MeasureMapper.class); } - public List selectLastMeasureForAllProjects(DbSession session, String metricKey) { - return mapper(session).selectLastMeasureForAllProjects(metricKey); - - } } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureMapper.java index fc395469f89..5b11e844677 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureMapper.java @@ -42,5 +42,4 @@ public interface MeasureMapper { void insert(MeasureDto measureDto); - List selectLastMeasureForAllProjects(@Param("metricKey") String metricKey); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectLocDistributionDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectLocDistributionDto.java new file mode 100644 index 00000000000..bd310099525 --- /dev/null +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectLocDistributionDto.java @@ -0,0 +1,27 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.measure; + +/** + * Loc distribution per language for the largest branch in a project. + */ +public record ProjectLocDistributionDto(String projectUuid, String branchUuid, String locDistribution) { + +} diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasureDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasureDto.java deleted file mode 100644 index 15c320a70f5..00000000000 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasureDto.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.measure; - -public class ProjectMeasureDto { - - private String projectUuid; - private Long lastAnalysis; - private long loc; - private String textValue; - - public String getProjectUuid() { - return projectUuid; - } - - public ProjectMeasureDto setProjectUuid(String projectUuid) { - this.projectUuid = projectUuid; - return this; - } - - public String getTextValue() { - return textValue; - } - - public ProjectMeasureDto setTextValue(String textValue) { - this.textValue = textValue; - return this; - } - - public long getLoc() { - return loc; - } - - public ProjectMeasureDto setLoc(long loc) { - this.loc = loc; - return this; - } - - public Long getLastAnalysis() { - return lastAnalysis; - } - - public ProjectMeasureDto setLastAnalysis(Long lastAnalysis) { - this.lastAnalysis = lastAnalysis; - return this; - } - -} diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml index 2612e083b46..23d5ba24e36 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml @@ -112,6 +112,24 @@ order by ncloc desc + - - -