]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7705 delete analysis measures using new ANALYSIS_UUID column
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 29 Jun 2016 15:35:03 +0000 (17:35 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 4 Jul 2016 13:20:30 +0000 (15:20 +0200)
sonar-db/src/main/java/org/sonar/db/purge/PurgeCommands.java
sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java
sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml

index b8035f09342596ea7c894f51d1c6087670d1b701..c959a9497953919cbe80f1ab9a454f0177133366 100644 (file)
@@ -195,13 +195,7 @@ class PurgeCommands {
     profiler.stop();
 
     profiler.start("deleteAnalyses (project_measures)");
-    analysisIdsPartitions.forEach(analysisIdsPartition -> {
-      purgeMapper.deleteSnapshotMeasures(analysisIdsPartition);
-      for (Long analysisId : analysisIdsPartition) {
-        List<List<Long>> snapshotIdPartitions = Lists.partition(purgeMapper.selectDescendantsSnapshotIds(analysisId), MAX_SNAPSHOTS_PER_QUERY);
-        snapshotIdPartitions.forEach(purgeMapper::deleteSnapshotMeasures);
-      }
-    });
+    analysisUuidsPartitions.forEach(purgeMapper::deleteAnalysisMeasures);
     session.commit();
     profiler.stop();
 
index bc8cb45ebc57407e921ea07819ea55695c3ef06f..fc2ec93eff3b6118d096982959acff2b5744b6ce 100644 (file)
@@ -32,8 +32,6 @@ public interface PurgeMapper {
    */
   List<IdUuidPair> selectComponentsByProjectUuid(String projectUuid);
 
-  List<Long> selectDescendantsSnapshotIds(@Param("analysisId") long analysisId);
-
   void deleteAnalyses(@Param("analysisUuids") List<String> analysisUuids);
 
   void deleteDescendantSnapshots(@Param("snapshotIds") List<Long> snapshotIds);
@@ -44,6 +42,8 @@ public interface PurgeMapper {
 
   void deleteSnapshotEvents(@Param("analysisUuids") List<String> analysisUuids);
 
+  void deleteAnalysisMeasures(@Param("analysisUuids") List<String> analysisUuids);
+
   void deleteSnapshotMeasures(@Param("snapshotIds") List<Long> snapshotIds);
 
   List<Long> selectMetricIdsWithoutHistoricalData();
index 2ec4712452af4d6ae8df21b689bb91cb09d8d309..a1bcc6315075a57203f90e58a4e738bafdba1e19 100644 (file)
     select id, uuid from projects where project_uuid=#{uuid} or uuid=#{uuid}
   </select>
 
-  <select id="selectDescendantsSnapshotIds" resultType="long" parameterType="long">
-    select id from snapshots where root_snapshot_id=#{analysisId}
-  </select>
+  <delete id="deleteAnalysisMeasures" parameterType="map">
+    delete from project_measures
+    where
+      analysis_uuid in
+      <foreach collection="analysisUuids" open="(" close=")" item="analysisUuid" separator=",">
+        #{analysisUuid}
+      </foreach>
+  </delete>
 
   <delete id="deleteSnapshotMeasures" parameterType="map">
     delete from project_measures