From 74384e67058fcfea16c80839740d28d9083b944a Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Thu, 19 Mar 2020 13:53:23 -0500 Subject: SONAR-12691 Don't persist project measures that are not historical --- .../main/java/org/sonar/db/measure/MeasureDao.java | 9 ----- .../java/org/sonar/db/measure/MeasureMapper.java | 3 -- .../java/org/sonar/db/measure/MeasureQuery.java | 1 + .../java/org/sonar/db/purge/PurgeCommands.java | 9 ----- .../main/java/org/sonar/db/purge/PurgeMapper.java | 4 --- .../org/sonar/db/measure/MeasureMapper.xml | 10 ------ .../resources/org/sonar/db/purge/PurgeMapper.xml | 18 ---------- .../java/org/sonar/db/purge/PurgeCommandsTest.java | 38 ---------------------- .../test/java/org/sonar/db/purge/PurgeDaoTest.java | 38 ---------------------- 9 files changed, 1 insertion(+), 129 deletions(-) (limited to 'server/sonar-db-dao/src') 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 e3f36923d01..c27e4d0d835 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 @@ -74,15 +74,6 @@ public class MeasureDao implements Dao { return mapper(dbSession).selectByQueryOnSingleComponent(query); } - public List selectPastMeasures(DbSession dbSession, String componentUuid, String analysisUuid, Collection metricIds) { - if (metricIds.isEmpty()) { - return emptyList(); - } - return executeLargeInputs( - metricIds, - ids -> mapper(dbSession).selectPastMeasuresOnSingleAnalysis(componentUuid, analysisUuid, ids)); - } - /** * Select measures of: * - one component 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 d98be0bbf21..5892ec457b0 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 @@ -44,9 +44,6 @@ public interface MeasureMapper { List selectByQueryOnSingleComponent(@Param("query") MeasureQuery query); - List selectPastMeasuresOnSingleAnalysis(@Param("componentUuid") String componentUuid, @Param("analysisUuid") String analysisUuid, - @Param("metricIds") List metricIds); - List selectPastMeasuresOnSeveralAnalyses(@Param("query") PastMeasureQuery query); void insert(MeasureDto measureDto); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureQuery.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureQuery.java index 5ef8e2f9eaa..7113fca91ac 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureQuery.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureQuery.java @@ -65,6 +65,7 @@ public class MeasureQuery { this.metricKeys = metricKeys; } + @CheckForNull public String getAnalysisUuid() { return analysisUuid; } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java index b27aa2fcf14..ac0cabedd62 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java @@ -134,15 +134,6 @@ class PurgeCommands { deleteAnalysisDuplications(analysisUuidsPartitions); - profiler.start("deleteSnapshotWastedMeasures (project_measures)"); - List metricIdsWithoutHistoricalData = purgeMapper.selectMetricIdsWithoutHistoricalData(); - if (!metricIdsWithoutHistoricalData.isEmpty()) { - analysisUuidsPartitions - .forEach(analysisUuidsPartition -> purgeMapper.deleteAnalysisWastedMeasures(analysisUuidsPartition, metricIdsWithoutHistoricalData)); - session.commit(); - } - profiler.stop(); - profiler.start("updatePurgeStatusToOne (snapshots)"); analysisUuidsPartitions.forEach(purgeMapper::updatePurgeStatusToOne); session.commit(); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java index 07052cbed3b..5000b6fcbec 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java @@ -54,10 +54,6 @@ public interface PurgeMapper { void fullDeleteComponentMeasures(@Param("componentUuids") List componentUuids); - List selectMetricIdsWithoutHistoricalData(); - - void deleteAnalysisWastedMeasures(@Param("analysisUuids") List analysisUuids, @Param("metricIds") List metricIds); - /** * Purge status flag is used to not attempt to remove duplications & historical data of analyses * for which we already removed them. diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/MeasureMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/MeasureMapper.xml index 64c92258fdc..dafc59b1939 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/MeasureMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/MeasureMapper.xml @@ -97,16 +97,6 @@ - - - -