diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-06-11 10:58:54 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-06-13 17:15:42 +0200 |
commit | 58ee80ddc8173adf55c358fd63bec8ebf780bdfd (patch) | |
tree | 13c1cee3248920208daf8fc9ae25bb40505d4654 | |
parent | 12c991a690e5d9c4b4cfd3f0f539ca8346777ecb (diff) | |
download | sonarqube-58ee80ddc8173adf55c358fd63bec8ebf780bdfd.tar.gz sonarqube-58ee80ddc8173adf55c358fd63bec8ebf780bdfd.zip |
SONAR-7501 remove usage of columns in SQL requests
29 files changed, 167 insertions, 389 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterCondition.java b/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterCondition.java index 3deaa13005d..5e3307b2f81 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterCondition.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterCondition.java @@ -119,9 +119,6 @@ public class MeasureFilterCondition { sql.append(textValue); } sql.append(" AND "); - sql.append(table).append(".rule_id IS NULL AND "); - sql.append(table).append(".rule_priority IS NULL AND "); - sql.append(table).append(".characteristic_id IS NULL AND "); sql.append(table).append(".person_id IS NULL "); return sql; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterSql.java b/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterSql.java index c2ee2b6aed2..e93c253bce5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterSql.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilterSql.java @@ -34,8 +34,8 @@ import javax.annotation.Nullable; import org.apache.commons.dbutils.DbUtils; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; -import org.sonar.db.component.SnapshotDto; import org.sonar.db.Database; +import org.sonar.db.component.SnapshotDto; import org.sonar.db.dialect.MsSql; import org.sonar.db.dialect.Oracle; @@ -114,7 +114,7 @@ class MeasureFilterSql { if (filter.sort().isOnMeasure()) { sb.append(" LEFT OUTER JOIN project_measures pmsort ON s.id=pmsort.snapshot_id AND pmsort.metric_id="); sb.append(filter.sort().metric().getId()); - sb.append(" AND pmsort.rule_id IS NULL AND pmsort.rule_priority IS NULL AND pmsort.characteristic_id IS NULL AND pmsort.person_id IS NULL "); + sb.append(" AND pmsort.person_id IS NULL "); } sb.append(" WHERE "); diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/hotspot_metric.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/hotspot_metric.html.erb index bd08df4bf43..f30310c2ba0 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/hotspot_metric.html.erb +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/hotspot_metric.html.erb @@ -15,7 +15,7 @@ snapshots_values[:root_sid] = (@snapshot.root_snapshot_id || @snapshot.id) snapshots_values[:path]="#{@snapshot.path}#{@snapshot.id}.%" - measures_conditions = ["project_measures.rule_id IS NULL", "project_measures.person_id IS NULL"] + measures_conditions = ["project_measures.person_id IS NULL"] measures_values = {} measures_conditions << "project_measures.metric_id = :m_id" measures_values[:m_id] = metric.id diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/time_machine.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/time_machine.html.erb index 4fcb2f845d4..66c6d6c7396 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/time_machine.html.erb +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/time_machine.html.erb @@ -28,7 +28,7 @@ sids = snapshots.collect { |s| s.id }.uniq measures=ProjectMeasure.find(:all, :conditions => - ["snapshot_id IN (:snapshot_id) AND metric_id IN (:metric_id) AND rule_id IS NULL AND person_id IS NULL", + ["snapshot_id IN (:snapshot_id) AND metric_id IN (:metric_id) AND person_id IS NULL", {:snapshot_id => sids, :metric_id => metric_ids} ] ) diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java index 7d429e9c122..f62a579d8d5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java @@ -404,17 +404,16 @@ public class PersistMeasuresStepTest extends BaseStepTest { private List<Map<String, Object>> selectSnapshots() { return dbTester .select( - "SELECT snapshot_id as \"snapshotId\", project_id as \"componentId\", metric_id as \"metricId\", rule_id as \"ruleId\", characteristic_id as \"characteristicId\", person_id as \"developerId\", " - + - "value as \"value\", text_value as \"textValue\", " + - "rule_priority as \"severity\", " + - "variation_value_1 as \"variation_value_1\", " + - "variation_value_2 as \"variation_value_2\", " + - "variation_value_3 as \"variation_value_3\", " + - "variation_value_4 as \"variation_value_4\", " + - "variation_value_5 as \"variation_value_5\"" + - "FROM project_measures " + - "ORDER by snapshot_id asc"); + "SELECT snapshot_id as \"snapshotId\", project_id as \"componentId\", metric_id as \"metricId\", person_id as \"developerId\", " + + + "value as \"value\", text_value as \"textValue\", " + + "variation_value_1 as \"variation_value_1\", " + + "variation_value_2 as \"variation_value_2\", " + + "variation_value_3 as \"variation_value_3\", " + + "variation_value_4 as \"variation_value_4\", " + + "variation_value_5 as \"variation_value_5\"" + + "FROM project_measures " + + "ORDER by snapshot_id asc"); } @Override diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/MeasureFilterConditionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/MeasureFilterConditionTest.java index f4422c7e79c..dd8bf7ea9c5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/MeasureFilterConditionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/MeasureFilterConditionTest.java @@ -62,7 +62,7 @@ public class MeasureFilterConditionTest { assertThat(condition.textValue()).isNull(); assertThat(condition.appendSqlColumn(new StringBuilder(), 1).toString()).isEqualTo("pmcond1.value"); assertThat(condition.toString()).isNotEmpty(); - assertThat(condition.appendSqlCondition(new StringBuilder(), 1).toString()).isEqualTo(" pmcond1.metric_id=123 AND pmcond1.value > 10.0 AND pmcond1.rule_id IS NULL AND pmcond1.rule_priority IS NULL AND pmcond1.characteristic_id IS NULL AND pmcond1.person_id IS NULL "); + assertThat(condition.appendSqlCondition(new StringBuilder(), 1).toString()).isEqualTo(" pmcond1.metric_id=123 AND pmcond1.value > 10.0 AND pmcond1.person_id IS NULL "); } @Test @@ -78,7 +78,8 @@ public class MeasureFilterConditionTest { assertThat(condition.value()).isEqualTo(10.0); assertThat(condition.appendSqlColumn(new StringBuilder(), 2).toString()).isEqualTo("pmcond2.variation_value_3"); assertThat(condition.toString()).isNotEmpty(); - assertThat(condition.appendSqlCondition(new StringBuilder(), 2).toString()).isEqualTo(" pmcond2.metric_id=123 AND pmcond2.variation_value_3 <= 10.0 AND pmcond2.rule_id IS NULL AND pmcond2.rule_priority IS NULL AND pmcond2.characteristic_id IS NULL AND pmcond2.person_id IS NULL "); + assertThat(condition.appendSqlCondition(new StringBuilder(), 2).toString()) + .isEqualTo(" pmcond2.metric_id=123 AND pmcond2.variation_value_3 <= 10.0 AND pmcond2.person_id IS NULL "); } @Test @@ -94,6 +95,6 @@ public class MeasureFilterConditionTest { assertThat(condition.textValue()).isEqualTo("\"foo\""); assertThat(condition.appendSqlColumn(new StringBuilder(), 1).toString()).isEqualTo("pmcond1.text_value"); assertThat(condition.toString()).isNotEmpty(); - assertThat(condition.appendSqlCondition(new StringBuilder(), 1).toString()).isEqualTo(" pmcond1.metric_id=123 AND pmcond1.text_value = \"foo\" AND pmcond1.rule_id IS NULL AND pmcond1.rule_priority IS NULL AND pmcond1.characteristic_id IS NULL AND pmcond1.person_id IS NULL "); + assertThat(condition.appendSqlCondition(new StringBuilder(), 1).toString()).isEqualTo(" pmcond1.metric_id=123 AND pmcond1.text_value = \"foo\" AND pmcond1.person_id IS NULL "); } } diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/FillMeasuresWithVariationsStepTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/FillMeasuresWithVariationsStepTest/shared.xml index 9147c076e74..b89e3fcd691 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/FillMeasuresWithVariationsStepTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/FillMeasuresWithVariationsStepTest/shared.xml @@ -32,20 +32,20 @@ <!-- project measures --> <project_measures id="1" VALUE="60" METRIC_ID="1" SNAPSHOT_ID="1000" - RULE_ID="[null]" text_value="[null]" measure_date="[null]" project_id="[null]" - characteristic_id="[null]" url="[null]" person_id="[null]"/> + text_value="[null]" project_id="[null]" + person_id="[null]"/> <project_measures id="2" VALUE="80" METRIC_ID="2" SNAPSHOT_ID="1000" - RULE_ID="[null]" text_value="[null]" measure_date="[null]" project_id="[null]" - characteristic_id="[null]" url="[null]" person_id="[null]"/> + text_value="[null]" project_id="[null]" + person_id="[null]"/> <!-- package measures --> <project_measures id="3" VALUE="20" METRIC_ID="1" SNAPSHOT_ID="1001" - RULE_ID="[null]" text_value="[null]" measure_date="[null]" project_id="[null]" - characteristic_id="[null]" url="[null]" person_id="[null]"/> + text_value="[null]" project_id="[null]" + person_id="[null]"/> <project_measures id="4" VALUE="70" METRIC_ID="2" SNAPSHOT_ID="1001" - RULE_ID="[null]" text_value="[null]" measure_date="[null]" project_id="[null]" - characteristic_id="[null]" url="[null]" person_id="[null]"/> + text_value="[null]" project_id="[null]" + person_id="[null]"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest/insert-from-index-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest/insert-from-index-result.xml index 644a0bcd53e..ae4934573a6 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest/insert-from-index-result.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest/insert-from-index-result.xml @@ -2,6 +2,5 @@ <project_measures snapshot_id="1000" metric_id="10" value="6.0" project_id="[null]" text_value="[null]" measure_data="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]" - alert_status="[null]" alert_text="[null]" characteristic_id="[null]" description="[null]" measure_date="[null]" person_id="[null]" - rule_id="[null]" rule_priority="[null]" rules_category_id="[null]" tendency="[null]" url="[null]" /> -</dataset>
\ No newline at end of file + alert_status="[null]" alert_text="[null]" description="[null]" person_id="[null]"/> +</dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest/insert-from-report-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest/insert-from-report-result.xml index 1262c51c16f..b6a2431d6e8 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest/insert-from-report-result.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest/insert-from-report-result.xml @@ -2,6 +2,5 @@ <project_measures snapshot_id="1000" metric_id="10" value="3.0" project_id="[null]" text_value="[null]" measure_data="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]" - alert_status="[null]" alert_text="[null]" characteristic_id="[null]" description="[null]" measure_date="[null]" person_id="[null]" - rule_id="[null]" rule_priority="[null]" rules_category_id="[null]" tendency="[null]" url="[null]" /> -</dataset>
\ No newline at end of file + alert_status="[null]" alert_text="[null]" description="[null]" person_id="[null]"/> +</dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_person_measures.xml b/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_person_measures.xml index 8cf1a3b824e..f17b71c5c73 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_person_measures.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_person_measures.xml @@ -20,25 +20,25 @@ <!-- standard measure --> <project_measures id="1001" metric_id="1" value="500" snapshot_id="101" person_id="[null]" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" + variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="400" - rule_priority="[null]" alert_text="[null]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" characteristic_id="[null]"/> + alert_text="[null]" + text_value="[null]" project_id="[null]" + alert_status="[null]" description="[null]"/> <!-- details of the measure by person --> <project_measures id="1002" metric_id="1" value="300" snapshot_id="101" person_id="30000" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" + variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="400" - rule_priority="[null]" alert_text="[null]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" characteristic_id="[null]"/> + alert_text="[null]" + text_value="[null]" project_id="[null]" + alert_status="[null]" description="[null]"/> <project_measures id="1003" metric_id="1" value="200" snapshot_id="101" person_id="40000" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" + variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="400" - rule_priority="[null]" alert_text="[null]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" characteristic_id="[null]"/> + alert_text="[null]" + text_value="[null]" project_id="[null]" + alert_status="[null]" description="[null]"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_quality_model_measures.xml b/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_quality_model_measures.xml index d41fbb93ce9..964996ea17f 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_quality_model_measures.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_quality_model_measures.xml @@ -19,26 +19,26 @@ <!-- standard measure --> - <project_measures id="1001" metric_id="1" value="500" snapshot_id="101" characteristic_id="[null]" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" + <project_measures id="1001" metric_id="1" value="500" snapshot_id="101" + variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="400" - rule_priority="[null]" alert_text="[null]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" + alert_text="[null]" + text_value="[null]" project_id="[null]" alert_status="[null]" description="[null]" person_id="[null]"/> <!-- details of the measure by model characteristic --> - <project_measures id="1002" metric_id="1" value="300" snapshot_id="101" characteristic_id="30000" + <!--project_measures id="1002" metric_id="1" value="300" snapshot_id="101" characteristic_id="30000" url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="400" rule_priority="[null]" alert_text="[null]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" person_id="[null]"/> + text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" + alert_status="[null]" description="[null]" person_id="[null]"/>--> - <project_measures id="1003" metric_id="1" value="200" snapshot_id="101" characteristic_id="40000" + <!--project_measures id="1003" metric_id="1" value="200" snapshot_id="101" characteristic_id="40000" url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="400" rule_priority="[null]" alert_text="[null]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" person_id="[null]"/> + text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" + alert_status="[null]" description="[null]" person_id="[null]"/>--> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/shared.xml index 7adb0a9cefa..db520d39eb5 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/shared.xml @@ -83,48 +83,48 @@ <!-- lines, variation during period 5 --> <project_measures id="1001" metric_id="1" value="510" snapshot_id="101" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" + variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="400" - rule_priority="[null]" alert_text="[null]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" characteristic_id="[null]"/> + alert_text="[null]" + text_value="[null]" project_id="[null]" + alert_status="[null]" description="[null]"/> <project_measures id="1002" metric_id="1" value="510" snapshot_id="102" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[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]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" characteristic_id="[null]"/> + alert_text="[null]" + text_value="[null]" project_id="[null]" + alert_status="[null]" description="[null]"/> <project_measures id="1003" metric_id="1" value="500" snapshot_id="103" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[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]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" characteristic_id="[null]"/> + alert_text="[null]" + text_value="[null]" project_id="[null]" + alert_status="[null]" description="[null]"/> <project_measures id="1004" metric_id="1" value="10" snapshot_id="104" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[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]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" characteristic_id="[null]"/> + alert_text="[null]" + text_value="[null]" project_id="[null]" + alert_status="[null]" description="[null]"/> <!-- profile of java project --> <project_measures id="1005" metric_id="2" value="[null]" snapshot_id="101" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[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]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="Sonar way" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" characteristic_id="[null]"/> + alert_text="[null]" + text_value="Sonar way" project_id="[null]" + alert_status="[null]" description="[null]"/> <!-- coverage of java project --> <project_measures id="1006" metric_id="3" value="12.3" snapshot_id="101" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[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]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="Sonar way" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" characteristic_id="[null]"/> + alert_text="[null]" + text_value="Sonar way" project_id="[null]" + alert_status="[null]" description="[null]"/> <!-- php project --> <projects kee="php_project" long_name="PHP project" scope="PRJ" qualifier="TRK" name="PHP project" @@ -144,18 +144,18 @@ <!-- lines, many new lines during period 5 --> <project_measures id="1010" metric_id="1" value="5000" snapshot_id="110" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" + variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="4900" - rule_priority="[null]" alert_text="[null]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" characteristic_id="[null]"/> + alert_text="[null]" + text_value="[null]" project_id="[null]" + alert_status="[null]" description="[null]"/> <project_measures id="1011" metric_id="2" value="[null]" snapshot_id="110" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[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]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="php way" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" characteristic_id="[null]"/> + alert_text="[null]" + text_value="php way" project_id="[null]" + alert_status="[null]" description="[null]"/> <resource_index id="1" kee="java project" position="0" name_size="12" component_uuid="ABCD" root_component_uuid="ABCD" qualifier="TRK"/> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/sort_by_alert.xml b/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/sort_by_alert.xml index 370ac96a5fb..24180d95e1a 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/sort_by_alert.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/sort_by_alert.xml @@ -23,11 +23,11 @@ <!-- alert --> <project_measures id="1001" metric_id="5" value="510" snapshot_id="101" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" + variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="400" - rule_priority="[null]" alert_text="[null]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="WARN" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" characteristic_id="[null]"/> + alert_text="[null]" + text_value="WARN" project_id="[null]" + alert_status="[null]" description="[null]"/> <!-- php project --> <projects kee="php_project" long_name="PHP project" scope="PRJ" qualifier="TRK" name="PHP project" @@ -49,9 +49,9 @@ <project_measures id="1010" metric_id="5" value="5000" snapshot_id="110" 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]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="OK" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" characteristic_id="[null]"/> + alert_text="[null]" + text_value="OK" project_id="[null]" + alert_status="[null]" description="[null]"/> <!-- js project --> <projects kee="js_project" long_name="JS project" scope="PRJ" qualifier="TRK" name="JS project" @@ -71,11 +71,11 @@ <!-- alert --> <project_measures id="1020" metric_id="5" value="5000" snapshot_id="120" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[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]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="ERROR" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" characteristic_id="[null]"/> + alert_text="[null]" + text_value="ERROR" project_id="[null]" + alert_status="[null]" description="[null]"/> </dataset> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb index bebd548773c..35f9baa870b 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb @@ -126,7 +126,6 @@ class Api::ResourcesController < Api::ApiController measures_limit = nil measures_by_sid={} measures=nil - rules_by_id=nil if params['scopes'] snapshots_conditions << 'snapshots.scope in (:scopes)' @@ -164,7 +163,6 @@ class Api::ResourcesController < Api::ApiController end if params['metrics'] && params['metrics']!='false' - set_backward_compatible load_measures=true if params['metrics']!='true' @@ -184,7 +182,6 @@ class Api::ResourcesController < Api::ApiController end measures_conditions << 'project_measures.person_id IS NULL' - add_rule_filters(measures_conditions, measures_values) measures=ProjectMeasure.all(:joins => :snapshot, :select => select_columns_for_measures, @@ -204,14 +201,6 @@ class Api::ResourcesController < Api::ApiController snapshots_values[:sids] = (measures_by_sid.empty? ? [-1] : measures_by_sid.keys) end - # load coding rules - rules_by_id={} - rule_ids=measures.map { |m| m.rule_id }.compact.uniq - unless rule_ids.empty? - Rule.find(rule_ids).each do |rule| - rules_by_id[rule.id]=rule - end - end end # ---------- LOAD RESOURCES @@ -259,7 +248,7 @@ class Api::ResourcesController < Api::ApiController sorted_resources=sorted_resources.uniq.compact # ---------- FORMAT RESPONSE - objects={:sorted_resources => sorted_resources, :snapshots_by_rid => snapshots_by_rid, :measures_by_sid => measures_by_sid, :params => params, :rules_by_id => rules_by_id} + objects={:sorted_resources => sorted_resources, :snapshots_by_rid => snapshots_by_rid, :measures_by_sid => measures_by_sid, :params => params} respond_to do |format| format.json { render :json => jsonp(to_json(objects)) } format.xml { render :xml => to_xml(objects) } @@ -272,15 +261,8 @@ class Api::ResourcesController < Api::ApiController private - def set_backward_compatible - # backward-compatibility with sonar 1.9 - if params['filter_rules'] - (params['filter_rules']=='true') ? params['rules']='false' : params['rules']='true' - end - end - def select_columns_for_measures - select_columns='project_measures.id,project_measures.value,project_measures.metric_id,project_measures.snapshot_id,project_measures.rule_id,project_measures.text_value,project_measures.measure_data' + select_columns='project_measures.id,project_measures.value,project_measures.metric_id,project_measures.snapshot_id,project_measures.text_value,project_measures.measure_data' if params[:includetrends]=='true' select_columns+=',project_measures.variation_value_1,project_measures.variation_value_2,project_measures.variation_value_3,project_measures.variation_value_4,project_measures.variation_value_5' end @@ -293,34 +275,16 @@ class Api::ResourcesController < Api::ApiController select_columns end - def add_rule_filters(measures_conditions, measures_values) - param_rules = params['rules'] || 'false' - if param_rules=='true' - measures_conditions << "project_measures.rule_id IS NOT NULL" - - elsif param_rules=='false' - measures_conditions << "project_measures.rule_id IS NULL" - else - rule_ids=param_rules.split(',').map do |key_or_id| - Rule.to_i(key_or_id) - end - measures_conditions << 'project_measures.rule_id IN (:rule_ids)' - measures_values[:rule_ids]=rule_ids.compact - end - - end - def to_json(objects) resources = objects[:sorted_resources] snapshots_by_rid = objects[:snapshots_by_rid] measures_by_sid = objects[:measures_by_sid] - rules_by_id = objects[:rules_by_id] params = objects[:params] result=[] resources.each do |resource| snapshot=snapshots_by_rid[resource.id] - result<<resource_to_json(resource, snapshot, measures_by_sid[snapshot.id], rules_by_id, params) + result<<resource_to_json(resource, snapshot, measures_by_sid[snapshot.id], params) end result end @@ -329,7 +293,6 @@ class Api::ResourcesController < Api::ApiController resources = objects[:sorted_resources] snapshots_by_rid = objects[:snapshots_by_rid] measures_by_sid = objects[:measures_by_sid] - rules_by_id = objects[:rules_by_id] params = objects[:params] xml = Builder::XmlMarkup.new(:indent => 0) @@ -338,12 +301,12 @@ class Api::ResourcesController < Api::ApiController xml.resources do resources.each do |resource| snapshot=snapshots_by_rid[resource.id] - resource_to_xml(xml, resource, snapshot, measures_by_sid[snapshot.id], rules_by_id, params) + resource_to_xml(xml, resource, snapshot, measures_by_sid[snapshot.id], params) end end end - def resource_to_json(resource, snapshot, measures, rules_by_id, options={}) + def resource_to_json(resource, snapshot, measures, options={}) verbose=(options[:verbose]=='true') include_alerts=(options[:includealerts]=='true') include_trends=(options[:includetrends]=='true') @@ -415,17 +378,12 @@ class Api::ResourcesController < Api::ApiController json_measure[:var5]=measure.variation_value_5.to_f if measure.variation_value_5 json_measure[:fvar5]=measure.format_numeric_value(measure.variation_value_5.to_f) if measure.variation_value_5 end - if measure.rule_id - rule = rules_by_id[measure.rule_id] - json_measure[:rule_key] = rule.key if rule - json_measure[:rule_name] = rule.name if rule - end end end json end - def resource_to_xml(xml, resource, snapshot, measures, rules_by_id, options={}) + def resource_to_xml(xml, resource, snapshot, measures, options={}) verbose=(options[:verbose]=='true') include_alerts=(options[:includealerts]=='true') include_trends=(options[:includetrends]=='true') @@ -494,11 +452,6 @@ class Api::ResourcesController < Api::ApiController xml.var5(measure.variation_value_5.to_f) if measure.variation_value_5 xml.fvar5(measure.format_numeric_value(measure.variation_value_5.to_f)) if measure.variation_value_5 end - if measure.rule_id - rule = rules_by_id[measure.rule_id] - xml.rule_key(rule.key) if rule - xml.rule_name(rule.name) if rule - end end end end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/timemachine_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/timemachine_controller.rb index 037dadd20df..746e1a32418 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/timemachine_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/timemachine_controller.rb @@ -68,7 +68,7 @@ class Api::TimemachineController < Api::ApiController @measures_by_sid={} unless @metrics.empty? - sql_conditions = ['snapshots.project_id=:rid AND snapshots.status=:status AND project_measures.rule_id IS NULL AND project_measures.rule_priority IS NULL AND project_measures.person_id IS NULL'] + sql_conditions = ['snapshots.project_id=:rid AND snapshots.status=:status AND project_measures.person_id IS NULL'] sql_values = {:rid => @resource.id, :status => Snapshot::STATUS_PROCESSED} if params[:fromDateTime] diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb index f96887b5ded..ad9713b3dbe 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb @@ -277,7 +277,7 @@ class MeasureFilter < ActiveRecord::Base measures = [] snapshot_ids.each_slice(999) do |safe_for_oracle_ids| measures.concat(ProjectMeasure.all(:conditions => - ['rule_priority is null and rule_id is null and person_id is null and snapshot_id in (?) and metric_id in (?)', safe_for_oracle_ids, metric_ids] + ['person_id is null and snapshot_id in (?) and metric_id in (?)', safe_for_oracle_ids, metric_ids] )) end measures.each do |measure| @@ -313,7 +313,7 @@ class MeasureFilter < ActiveRecord::Base @base_row = Row.new(base_snapshot) unless metric_ids.empty? base_measures = ProjectMeasure.all(:conditions => - ['rule_priority is null and rule_id is null and person_id is null and snapshot_id=? and metric_id in (?)', base_snapshot.id, metric_ids] + ['person_id is null and snapshot_id=? and metric_id in (?)', base_snapshot.id, metric_ids] ) base_measures.each do |base_measure| @base_row.add_measure(base_measure) diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb index 7ea0b1c49a8..668c75ebd46 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project.rb @@ -147,7 +147,6 @@ class Project < ActiveRecord::Base ' where s.id=m.snapshot_id and ' + " s.status='%s' and " + ' s.project_id=%s and m.metric_id=%s ', 'P', self.id, metric_id]) + - ' and m.rule_id IS NULL and m.rule_priority IS NULL' + ' and m.person_id IS NULL' + ' order by s.created_at' create_chart_measures(Project.connection.select_all(sql), 'created_at', 'value') diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb index a64ee75cb3a..bd56a6cc854 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb @@ -41,6 +41,10 @@ class ProjectMeasure < ActiveRecord::Base write_attribute(:metric_id, m.id) if m.id end + def rule_measure? + false + end + def data if metric.data? text_value || measure_data diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb index f9e7287d589..f929f119e6f 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/snapshot.rb @@ -26,15 +26,14 @@ class Snapshot < ActiveRecord::Base belongs_to :parent_snapshot, :class_name => 'Snapshot', :foreign_key => 'parent_snapshot_id' belongs_to :root_snapshot, :class_name => 'Snapshot', :foreign_key => 'root_snapshot_id' - has_many :measures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NULL AND person_id IS NULL' - has_many :rulemeasures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NOT NULL AND person_id IS NULL', :include => 'rule' - has_many :person_measures, :class_name => 'ProjectMeasure', :conditions => 'rule_id IS NULL AND person_id IS NOT NULL' + has_many :measures, :class_name => 'ProjectMeasure', :conditions => 'person_id IS NULL' + has_many :person_measures, :class_name => 'ProjectMeasure', :conditions => 'person_id IS NOT NULL' has_many :events, :dependent => :destroy, :order => 'event_date DESC' STATUS_UNPROCESSED = 'U' STATUS_PROCESSED = 'P' - + def created_at long_to_date(:created_at) end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/trends_chart.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/trends_chart.rb index 2510866597d..0780981546e 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/trends_chart.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/trends_chart.rb @@ -23,11 +23,10 @@ class TrendsChart unless metric_ids.empty? sql= "select s.created_at as created_at, m.value as value, m.metric_id as metric_id, s.id as sid " + " from project_measures m LEFT OUTER JOIN snapshots s ON s.id=m.snapshot_id " + - " where m.rule_id is null " + - " and s.status=? " + + " where s.status=? " + " and s.project_id=? " + " and m.metric_id in (?) " + - " and m.rule_priority is null and m.person_id is null" + " and m.person_id is null" if (options[:from]) sql += ' and s.created_at>=?' end diff --git a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/insert-result.xml b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/insert-result.xml index ce9ed90d98b..468afb6e0bd 100644 --- a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/insert-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/insert-result.xml @@ -3,15 +3,10 @@ id="1" snapshot_id="2" metric_id="3" - characteristic_id="[null]" - rule_id="[null]" project_id="6" person_id="23" value="2.0" text_value="measure-value" - tendency="[null]" - rule_priority="[null]" - measure_date="[null]" measure_data="[null]" variation_value_1="1.0" variation_value_2="2.0" @@ -20,8 +15,6 @@ variation_value_5="5.0" alert_status="alert" alert_text="alert-text" - url="[null]" description="measure-description" - rules_category_id="[null]" - /> + /> </dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml index 4cdaecd90fd..fd47744a14f 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml @@ -13,14 +13,12 @@ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="[false]" path="[null]"/> - <project_measures ID="1" characteristic_id="[null]" url="[null]" variation_value_1="[null]" variation_value_2="[null]" + <project_measures ID="1" 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" METRIC_ID="1" SNAPSHOT_ID="1" rules_category_id="[null]" - RULE_ID="[null]" + alert_text="[null]" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" person_id="[null]" - text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" + text_value="[null]" project_id="[null]" alert_status="[null]" description="[null]" measure_data="[null]"/> <events id="1" name="Version 1.0" component_uuid="1" snapshot_id="1" category="VERSION" description="[null]" event_date="1228222680000" created_at="1228222680000" event_data="[null]"/> diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteSnapshot.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteSnapshot.xml index 299c31cb5ce..bb9f3121059 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteSnapshot.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteSnapshot.xml @@ -12,13 +12,12 @@ build_date="1228222680000" version="[null]" path="[null]"/> - <project_measures ID="1" characteristic_id="[null]" url="[null]" variation_value_1="[null]" variation_value_2="[null]" + <project_measures ID="1" 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" METRIC_ID="1" SNAPSHOT_ID="1" rules_category_id="[null]" + alert_text="[null]" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" person_id="[null]" - text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" + text_value="[null]" project_id="[null]" alert_status="[null]" description="[null]" measure_data="[null]"/> <events id="1" name="Version 1.0" component_uuid="1" snapshot_id="1" category="VERSION" description="[null]" event_date="1228222680000" created_at="1228222680000" event_data="[null]"/> @@ -38,14 +37,12 @@ build_date="1228222680000" version="[null]" path="[null]"/> - <project_measures ID="2" characteristic_id="[null]" url="[null]" variation_value_1="[null]" variation_value_2="[null]" + <project_measures ID="2" 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" METRIC_ID="1" SNAPSHOT_ID="5" rules_category_id="[null]" - RULE_ID="[null]" + alert_text="[null]" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="5" person_id="[null]" - text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" + text_value="[null]" project_id="[null]" alert_status="[null]" description="[null]" measure_data="[null]"/> <events id="2" name="Version 1.0" component_uuid="5" snapshot_id="5" category="VERSION" description="[null]" event_date="1228222680000" created_at="1228222680000" event_data="[null]"/> diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml index 62301d952b6..7bb4215979f 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml @@ -22,52 +22,12 @@ build_date="1228222680000" version="[null]" path="[null]"/> <!-- do not delete standard measure --> - <project_measures id="1" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="[null]" metric_id="1" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" + <project_measures id="1" project_id="1" snapshot_id="1" metric_id="1" + 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]" + variation_value_5="[null]" alert_text="[null]" value="10.0" person_id="[null]" - text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" + text_value="[null]" alert_status="[null]" description="[null]" measure_data="[null]"/> - <!-- do not delete measure on characteristic --> - <project_measures id="3" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="1" 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]" measure_data="[null]"/> - - <!-- do not delete measure on characteristic --> - <project_measures id="4" 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]" measure_data="[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]" - 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]" measure_data="[null]"/>--> - - <!-- delete measure on developers --> - <!--<project_measures id="7" 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]" - person_id="123456" - variation_value_4="[null]" - variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" value="10.0" - rules_category_id="[null]" - text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" - description="[null]" measure_data="[null]"/>--> </dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml index 9475e5ec6fb..e5946cb30f6 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml @@ -22,52 +22,47 @@ build_date="1228222680000" version="[null]" path="[null]"/> <!-- do not delete standard measure --> - <project_measures id="1" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="[null]" metric_id="1" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" + <project_measures id="1" project_id="1" snapshot_id="1" metric_id="1" + 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]" + variation_value_5="[null]" alert_text="[null]" value="10.0" person_id="[null]" - text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" + text_value="[null]" alert_status="[null]" description="[null]" measure_data="[null]"/> <!-- do not delete measure on root characteristic --> - <project_measures id="3" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="1" metric_id="1" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" + <!--project_measures id="3" project_id="1" snapshot_id="1" characteristic_id="1" metric_id="1" + 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]" + variation_value_5="[null]" alert_text="[null]" value="10.0" person_id="[null]" - text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" - description="[null]" measure_data="[null]"/> + text_value="[null]" alert_status="[null]" + description="[null]" measure_data="[null]"/>--> <!-- do not delete measure on characteristic --> - <project_measures id="4" 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]" + <!--project_measures id="4" project_id="1" snapshot_id="1" characteristic_id="2" metric_id="1" + 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]" + variation_value_5="[null]" alert_text="[null]" value="10.0" person_id="[null]" - text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" - description="[null]" measure_data="[null]"/> + text_value="[null]" alert_status="[null]" + description="[null]" measure_data="[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]" + <project_measures id="6" project_id="1" snapshot_id="1" metric_id="2" + 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]" + variation_value_5="[null]" alert_text="[null]" value="10.0" person_id="[null]" - text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" + text_value="[null]" alert_status="[null]" description="[null]" measure_data="[null]"/> <!-- delete measure on developers --> - <project_measures id="7" 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]" + <project_measures id="7" project_id="1" snapshot_id="1" metric_id="2" + variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" person_id="123456" variation_value_4="[null]" - variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" value="10.0" - rules_category_id="[null]" - text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" + variation_value_5="[null]" alert_text="[null]" value="10.0" + text_value="[null]" alert_status="[null]" description="[null]" measure_data="[null]"/> </dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeSnapshot-result.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeSnapshot-result.xml index 370f4d3ab34..b349f6da5b3 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeSnapshot-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeSnapshot-result.xml @@ -19,18 +19,17 @@ Note that measures, events and reviews are not deleted. depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000" build_date="1228222680000" version="[null]" path="[null]"/> - <!--switched_off="[null]" permanent_id="[null]" RULE_ID="1" FAILURE_LEVEL="2"--> + <!--switched_off="[null]" permanent_id="[null]" FAILURE_LEVEL="2"--> <!--MESSAGE="msg1" LINE="[null]" COST="[null]"--> <!--created_at="2008-12-02 13:58:00.00"--> <!--checksum="[null]" person_id="[null]"/>--> - <project_measures ID="1" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="[null]" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" + <project_measures ID="1" project_id="1" SNAPSHOT_ID="1" + 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" METRIC_ID="1" - rules_category_id="[null]" + variation_value_5="[null]" alert_text="[null]" VALUE="10.0" METRIC_ID="1" person_id="[null]" - text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" + text_value="[null]" alert_status="[null]" description="[null]" measure_data="[null]"/> <events id="1" component_uuid="1" snapshot_id="1" @@ -55,13 +54,12 @@ Note that measures, events and reviews are not deleted. build_date="1228222680000" version="[null]" path="[null]"/> - <project_measures ID="2" project_id="2" SNAPSHOT_ID="2" RULE_ID="[null]" characteristic_id="[null]" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" + <project_measures ID="2" project_id="2" SNAPSHOT_ID="2" + 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" METRIC_ID="1" - rules_category_id="[null]" + variation_value_5="[null]" alert_text="[null]" VALUE="10.0" METRIC_ID="1" person_id="[null]" - text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" + text_value="[null]" alert_status="[null]" description="[null]" measure_data="[null]"/> <events id="2" component_uuid="2" snapshot_id="2" diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeSnapshot.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeSnapshot.xml index 53144869569..bbc1d50c7ab 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeSnapshot.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeSnapshot.xml @@ -11,11 +11,11 @@ depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000" build_date="1228222680000" version="[null]" path="[null]"/> - <project_measures ID="1" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="[null]" - 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" METRIC_ID="1" rules_category_id="[null]" person_id="[null]" text_value="[null]" - tendency="[null]" measure_date="[null]" alert_status="[null]" description="[null]" + <project_measures ID="1" project_id="1" SNAPSHOT_ID="1" + variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" + variation_value_4="[null]" variation_value_5="[null]" alert_text="[null]" + VALUE="10.0" METRIC_ID="1" person_id="[null]" text_value="[null]" + alert_status="[null]" description="[null]" measure_data="[null]"/> <events id="1" component_uuid="1" snapshot_id="1" @@ -39,13 +39,12 @@ depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000" build_date="1228222680000" version="[null]" path="[null]"/> - <project_measures ID="2" project_id="2" SNAPSHOT_ID="2" RULE_ID="[null]" characteristic_id="[null]" - url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" + <project_measures ID="2" project_id="2" SNAPSHOT_ID="2" + 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" METRIC_ID="1" - rules_category_id="[null]" + variation_value_5="[null]" alert_text="[null]" VALUE="10.0" METRIC_ID="1" person_id="[null]" - text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]" + text_value="[null]" alert_status="[null]" description="[null]" measure_data="[null]"/> <events id="2" component_uuid="2" snapshot_id="2" diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v45/DeleteMeasuresOnDeletedProfilesMigrationTest/before.xml b/sonar-db/src/test/resources/org/sonar/db/version/v45/DeleteMeasuresOnDeletedProfilesMigrationTest/before.xml deleted file mode 100644 index 14e559f4a12..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v45/DeleteMeasuresOnDeletedProfilesMigrationTest/before.xml +++ /dev/null @@ -1,34 +0,0 @@ -<dataset> - <metrics id="1" name="quality_profiles" VAL_TYPE="DATA" DESCRIPTION="[null]" domain="[null]" short_name="" - enabled="[true]" worst_value="0" optimized_best_value="[true]" best_value="100" direction="1" - hidden="[false]" delete_historical_data="[null]"/> - - <!-- old format, references a numeric value which is profile id --> - <project_measures id="1" VALUE="60" METRIC_ID="1" SNAPSHOT_ID="1001" alert_text="[null]" RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" - url="[null]" - variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" - variation_value_4="[null]" variation_value_5="[null]"/> - - <!-- new format, json data --> - <project_measures id="2" VALUE="[null]" text_value="{json}" METRIC_ID="1" SNAPSHOT_ID="1001" alert_text="[null]" - RULES_CATEGORY_ID="[null]" - RULE_ID="[null]" tendency="[null]" measure_date="[null]" project_id="[null]" - alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" - url="[null]" - variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" - variation_value_4="[null]" variation_value_5="[null]"/> - - <!-- last snapshot --> - <snapshots purge_status="[null]" id="1001" project_id="1" parent_snapshot_id="[null]" root_project_id="1" - root_snapshot_id="[null]" - scope="PRJ" qualifier="TRK" created_at="2009-11-01 13:58:00.00" build_date="2009-11-01 13:58:00.00" - version="[null]" path="" - status="P" islast="[true]" depth="0" - period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" - period2_param="[null]" period2_date="[null]" - period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" - period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" - period5_date="[null]"/> -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v45/DeleteMeasuresOnDeletedProfilesMigrationTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/version/v45/DeleteMeasuresOnDeletedProfilesMigrationTest/schema.sql deleted file mode 100644 index 912fd080b0d..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v45/DeleteMeasuresOnDeletedProfilesMigrationTest/schema.sql +++ /dev/null @@ -1,77 +0,0 @@ -CREATE TABLE "PROJECT_MEASURES" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "SNAPSHOT_ID" INTEGER, - "RULE_ID" INTEGER, - "RULES_CATEGORY_ID" INTEGER, - "TEXT_VALUE" VARCHAR(4000), - "TENDENCY" INTEGER, - "MEASURE_DATE" TIMESTAMP, - "PROJECT_ID" INTEGER, - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "URL" VARCHAR(2000), - "DESCRIPTION" VARCHAR(4000), - "RULE_PRIORITY" INTEGER, - "CHARACTERISTIC_ID" INTEGER, - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BINARY(167772150) -); - -CREATE TABLE "METRICS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER NOT NULL DEFAULT 0, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN NOT NULL DEFAULT FALSE, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "ORIGIN" VARCHAR(3), - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN -); - -CREATE TABLE "SNAPSHOTS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "CREATED_AT" TIMESTAMP, - "BUILD_DATE" TIMESTAMP, - "PROJECT_ID" INTEGER NOT NULL, - "PARENT_SNAPSHOT_ID" INTEGER, - "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', - "PURGE_STATUS" INTEGER, - "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, - "SCOPE" VARCHAR(3), - "QUALIFIER" VARCHAR(10), - "ROOT_SNAPSHOT_ID" INTEGER, - "VERSION" VARCHAR(500), - "PATH" VARCHAR(500), - "DEPTH" INTEGER, - "ROOT_PROJECT_ID" INTEGER, - "PERIOD1_MODE" VARCHAR(100), - "PERIOD1_PARAM" VARCHAR(100), - "PERIOD1_DATE" TIMESTAMP, - "PERIOD2_MODE" VARCHAR(100), - "PERIOD2_PARAM" VARCHAR(100), - "PERIOD2_DATE" TIMESTAMP, - "PERIOD3_MODE" VARCHAR(100), - "PERIOD3_PARAM" VARCHAR(100), - "PERIOD3_DATE" TIMESTAMP, - "PERIOD4_MODE" VARCHAR(100), - "PERIOD4_PARAM" VARCHAR(100), - "PERIOD4_DATE" TIMESTAMP, - "PERIOD5_MODE" VARCHAR(100), - "PERIOD5_PARAM" VARCHAR(100), - "PERIOD5_DATE" TIMESTAMP -); |