]> source.dussan.org Git - sonarqube.git/commitdiff
Update purge as there's now no more requirements in characteristics
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 11 Mar 2014 09:49:06 +0000 (10:49 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 11 Mar 2014 09:52:07 +0000 (10:52 +0100)
sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java
sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml

index 38a07064e4915abf259bac66ef0108495e5ff49c..f2be30838c3abed9aac109eeb276f46e14a1b757 100644 (file)
 package org.sonar.core.purge;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import org.apache.ibatis.session.SqlSession;
 
 import java.util.List;
 
 class PurgeCommands {
-  private static final int MAX_CHARACTERISTICS_PER_QUERY = 1000;
+
   private static final int MAX_SNAPSHOTS_PER_QUERY = 1000;
   private static final int MAX_RESOURCES_PER_QUERY = 1000;
 
@@ -231,19 +230,6 @@ class PurgeCommands {
     }
     profiler.stop();
 
-    profiler.start("deleteSnapshotMeasuresOnCharacteristics (project_measures)");
-    List<Long> characteristicIds = purgeMapper.selectCharacteristicIdsToPurge();
-    if (!characteristicIds.isEmpty()) {
-      for (List<Long> partSnapshotIds : snapshotIdsPartition) {
-        // SONAR-3641 We cannot process all characteristics at once
-        for (List<Long> ids : Iterables.partition(characteristicIds, MAX_CHARACTERISTICS_PER_QUERY)) {
-          purgeMapper.deleteSnapshotMeasuresOnCharacteristics(partSnapshotIds, ids);
-        }
-      }
-      session.commit();
-    }
-    profiler.stop();
-
     profiler.start("updatePurgeStatusToOne (snapshots)");
     for (Long snapshotId : snapshotIds) {
       purgeMapper.updatePurgeStatusToOne(snapshotId);
index 2501ff8bd0d6112b4c5decf25fbfb444c068ead1..a6f3ab5a38bebf68e0761932278cd583c38865e4 100644 (file)
     select id from metrics where delete_historical_data=${_true}
   </select>
 
-  <select id="selectCharacteristicIdsToPurge" resultType="long">
-    select id from characteristics where rule_id is not null
-  </select>
-
   <select id="selectProjectIdsByRootId" resultType="long" parameterType="long">
     select id from projects where root_id=#{id} and scope='PRJ'
   </select>
     )
   </delete>
 
-  <delete id="deleteSnapshotMeasuresOnCharacteristics" parameterType="map">
-    delete from project_measures where snapshot_id in
-    <foreach collection="snapshotIds" open="(" close=")" item="snapshotId" separator=",">
-        #{snapshotId}
-    </foreach>
-    and (
-    <foreach item="cid" index="index" collection="cids" open="" separator=" OR " close="">characteristic_id=#{cid}</foreach>
-    )
-  </delete>
-
   <update id="updatePurgeStatusToOne" parameterType="long">
     update snapshots set purge_status = 1 where id = #{id}
   </update>
index ef9c9433014f3c873da99207aaa9e3335d26b389..d5ad7fc62d47a9da972056e03346e00c1f446c87 100644 (file)
                     text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
                     description="[null]"/>
 
-  <!-- delete measure on requirement -->
-  <!--<project_measures ID="5" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="2" METRIC_ID="1"
-                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
-                    variation_value_4="[null]"
-                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0"
-                    rules_category_id="[null]"
-                    person_id="[null]"
-                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
-                    description="[null]"/>-->
-
   <!-- delete measure on metrics that are flagged with delete_historical_data=true -->
   <!--<project_measures ID="6" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="[null]" METRIC_ID="2"
                     url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
index 3321a4d8cf87599871f84c85f881c6d86e178907..23ec5986e5ba4a1bccbd0a2d5a1507969d5d3580 100644 (file)
                     text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
                     description="[null]"/>
 
-  <!-- delete measure on requirement -->
-  <project_measures id="5" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="3" metric_id="1"
-                    url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
-                    variation_value_4="[null]"
-                    variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" value="10.0"
-                    rules_category_id="[null]"
-                    person_id="[null]"
-                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
-                    description="[null]"/>
-
   <!-- delete measure on metrics that are flagged with delete_historical_data=true -->
   <project_measures id="6" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="[null]" metric_id="2"
                     url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"