aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-12-05 18:11:22 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-12-05 18:11:22 +0100
commitdc6d1e96ddada06d60cbb7ab0e0a4d5ee0929317 (patch)
tree1aa1bd73b500fe6a5bfbfb54e7f56e7152ea7d57
parent7fb4ae00fc9915a1377b46f558fde655805153f6 (diff)
downloadsonarqube-dc6d1e96ddada06d60cbb7ab0e0a4d5ee0929317.tar.gz
sonarqube-dc6d1e96ddada06d60cbb7ab0e0a4d5ee0929317.zip
SONAR-10116 exclude person measures when populating live_measures
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasures.java2
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasuresTest.java13
2 files changed, 14 insertions, 1 deletions
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasures.java
index a7945be15d1..3af94449183 100644
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasures.java
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasures.java
@@ -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 "
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasuresTest.java
index 7a2fc7e9e2c..e396e5d02ba 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasuresTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v70/PopulateLiveMeasuresTest.java
@@ -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() {