]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10116 exclude person measures when populating live_measures
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 5 Dec 2017 17:11:22 +0000 (18:11 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 5 Dec 2017 17:11:22 +0000 (18:11 +0100)
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasures.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasuresTest.java

index a7945be15d17fc95fdfada9fab53fe2ccdbc222a..3af94449183f5b39f57404ccfd9bc39109ae2661 100644 (file)
@@ -46,7 +46,7 @@ public class PopulateLiveMeasures extends DataChange {
       "FROM project_measures pm " +
       "INNER JOIN projects p on p.uuid = pm.component_uuid " +
       "INNER JOIN snapshots s on s.uuid = pm.analysis_uuid " +
-      "WHERE s.islast = ?")
+      "WHERE s.islast = ? and pm.person_id is null")
       .setBoolean(1, true);
 
     massUpdate.update("INSERT INTO live_measures "
index 7a2fc7e9e2c5fd6c40e9c72d0e8339e0f23ee87d..e396e5d02babc9efbb0cc9a7b7b8def983be249f 100644 (file)
@@ -126,6 +126,19 @@ public class PopulateLiveMeasuresTest {
     measure2.put("VARIATION_VALUE_1", "345");
     measure2.put("MEASURE_DATA", "FFFF");
     db.executeInsert("PROJECT_MEASURES", measure2);
+
+    // measures with person_id not null are purged later
+    // by another migration
+    Map<String, Object> personMeasure = new HashMap<>();
+    personMeasure.put("COMPONENT_UUID", "PRJ1");
+    personMeasure.put("ANALYSIS_UUID", "A2");
+    personMeasure.put("METRIC_ID", "200");
+    personMeasure.put("VALUE", "234");
+    personMeasure.put("TEXT_VALUE", "TEXT_VALUEx");
+    personMeasure.put("VARIATION_VALUE_1", "345");
+    personMeasure.put("MEASURE_DATA", "FFFF");
+    personMeasure.put("PERSON_ID", "99");
+    db.executeInsert("PROJECT_MEASURES", personMeasure);
   }
 
   private List<Map<String, Object>> getLiveMeasures() {