diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2023-06-07 12:30:33 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-06-20 13:10:18 +0000 |
commit | 667618747b9e64f552eda5fc24df8398ca7afbef (patch) | |
tree | 642f7d84c3888e4081daff283acbbfe07116aff7 /server/sonar-webserver-core/src | |
parent | 93734208da4519e1872e80c59f7edd1612dac5da (diff) | |
download | sonarqube-667618747b9e64f552eda5fc24df8398ca7afbef.tar.gz sonarqube-667618747b9e64f552eda5fc24df8398ca7afbef.zip |
SONAR-19556 Refactor use of DB columns referencing projects or branches for Entities
Diffstat (limited to 'server/sonar-webserver-core/src')
3 files changed, 9 insertions, 8 deletions
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/issue/index/AsyncIssueIndexingImpl.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/issue/index/AsyncIssueIndexingImpl.java index dd0e001b6fe..6d68b9c1e9b 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/issue/index/AsyncIssueIndexingImpl.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/issue/index/AsyncIssueIndexingImpl.java @@ -153,12 +153,12 @@ public class AsyncIssueIndexingImpl implements AsyncIssueIndexing { } private void removeExistingIndexationTasksForProject(DbSession dbSession, String projectUuid) { - Set<String> ceQueueUuidsForProject = dbClient.ceQueueDao().selectByMainComponentUuid(dbSession, projectUuid) + Set<String> ceQueueUuidsForProject = dbClient.ceQueueDao().selectByEntityUuid(dbSession, projectUuid) .stream().filter(p -> p.getTaskType().equals(BRANCH_ISSUE_SYNC)) .map(CeQueueDto::getUuid).collect(Collectors.toSet()); Set<String> ceActivityUuidsForProject = dbClient.ceActivityDao().selectByTaskType(dbSession, BRANCH_ISSUE_SYNC) .stream() - .filter(ceActivityDto -> projectUuid.equals(ceActivityDto.getMainComponentUuid())) + .filter(ceActivityDto -> projectUuid.equals(ceActivityDto.getEntityUuid())) .map(CeActivityDto::getUuid).collect(Collectors.toSet()); removeIndexationTasks(dbSession, ceQueueUuidsForProject, ceActivityUuidsForProject); } diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java index c5fe2bfe8f2..3a02c634f39 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java @@ -53,6 +53,7 @@ import org.sonar.db.component.PrBranchAnalyzedLanguageCountByProjectDto; import org.sonar.db.component.SnapshotDto; import org.sonar.db.measure.LiveMeasureDto; import org.sonar.db.measure.ProjectLocDistributionDto; +import org.sonar.db.measure.ProjectMainBranchLiveMeasureDto; import org.sonar.db.metric.MetricDto; import org.sonar.db.newcodeperiod.NewCodePeriodDto; import org.sonar.db.qualitygate.ProjectQgateAssociationDto; @@ -413,9 +414,9 @@ public class TelemetryDataLoaderImpl implements TelemetryDataLoader { return Collections.emptyMap(); } - return dbClient.liveMeasureDao().selectForProjectsByMetricUuids(dbSession, metricNamesByUuid.keySet()) + return dbClient.liveMeasureDao().selectForProjectMainBranchesByMetricUuids(dbSession, metricNamesByUuid.keySet()) .stream() - .collect(groupingBy(LiveMeasureDto::getProjectUuid, + .collect(groupingBy(ProjectMainBranchLiveMeasureDto::getProjectUuid, toMap(lmDto -> metricNamesByUuid.get(lmDto.getMetricUuid()), lmDto -> Optional.ofNullable(lmDto.getValue()).orElseGet(() -> Double.valueOf(lmDto.getTextValue())), (oldValue, newValue) -> newValue, HashMap::new))); diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/issue/index/AsyncIssueIndexingImplTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/issue/index/AsyncIssueIndexingImplTest.java index a0907e93a35..73e11b8c33e 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/issue/index/AsyncIssueIndexingImplTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/issue/index/AsyncIssueIndexingImplTest.java @@ -175,16 +175,16 @@ public class AsyncIssueIndexingImplTest { dbTester.components().insertProjectBranch(projectDto, b -> b.setBranchType(BRANCH).setUuid(branchUuid)); CeQueueDto mainBranchTask = new CeQueueDto().setUuid("uuid_2").setTaskType(BRANCH_ISSUE_SYNC) - .setMainComponentUuid(projectDto.getUuid()).setComponentUuid(projectDto.getUuid()); + .setEntityUuid(projectDto.getUuid()).setComponentUuid(projectDto.getUuid()); dbClient.ceQueueDao().insert(dbTester.getSession(), mainBranchTask); CeQueueDto branchTask = new CeQueueDto().setUuid("uuid_3").setTaskType(BRANCH_ISSUE_SYNC) - .setMainComponentUuid(projectDto.getUuid()).setComponentUuid(branchUuid); + .setEntityUuid(projectDto.getUuid()).setComponentUuid(branchUuid); dbClient.ceQueueDao().insert(dbTester.getSession(), branchTask); ProjectDto anotherProjectDto = dbTester.components().insertPrivateProject().getProjectDto(); CeQueueDto taskOnAnotherProject = new CeQueueDto().setUuid("uuid_4").setTaskType(BRANCH_ISSUE_SYNC) - .setMainComponentUuid(anotherProjectDto.getUuid()).setComponentUuid("another-branchUuid"); + .setEntityUuid(anotherProjectDto.getUuid()).setComponentUuid("another-branchUuid"); CeActivityDto canceledTaskOnAnotherProject = new CeActivityDto(taskOnAnotherProject).setStatus(Status.CANCELED); dbClient.ceActivityDao().insert(dbTester.getSession(), canceledTaskOnAnotherProject); @@ -200,7 +200,7 @@ public class AsyncIssueIndexingImplTest { // verify that the canceled tasks on anotherProject is still here, and was not removed by the project reindexation assertThat(dbClient.ceActivityDao().selectByTaskType(dbTester.getSession(), BRANCH_ISSUE_SYNC)) .hasSize(1) - .extracting(CeActivityDto::getMainComponentUuid) + .extracting(CeActivityDto::getEntityUuid) .containsExactly(anotherProjectDto.getUuid()); assertThat(logTester.logs(Level.INFO)) |