summaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-03-03 09:32:33 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-03-03 09:32:33 +0100
commitfc1cef90f11560697ec0d0204de1308e00f3f702 (patch)
treeb02316516709e8367e28a5a936086c82acab42ec /sonar-server
parentbede6a079dea27853b924248901ee461c5a5b168 (diff)
downloadsonarqube-fc1cef90f11560697ec0d0204de1308e00f3f702.tar.gz
sonarqube-fc1cef90f11560697ec0d0204de1308e00f3f702.zip
SONAR-4996 Improve measure filter migration when values are at the end of the line
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/519_update_measure_filters_on_debt_to_minutes.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/519_update_measure_filters_on_debt_to_minutes.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/519_update_measure_filters_on_debt_to_minutes.rb
index d78e0c29135..0668cce6118 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/519_update_measure_filters_on_debt_to_minutes.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/519_update_measure_filters_on_debt_to_minutes.rb
@@ -47,9 +47,12 @@ class UpdateMeasureFiltersOnDebtToMinutes < ActiveRecord::Migration
data.scan(/c(\d+)_metric=(sqale_index|new_technical_debt|sqale_effort_to_grade_a|sqale_effort_to_grade_b|sqale_effort_to_grade_c|sqale_effort_to_grade_d|blocker_remediation_cost
|critical_remediation_cost|major_remediation_cost|minor_remediation_cost|info_remediation_cost)/) do |find|
index = find[0]
- value = /c#{index}_val=((.+?)\|)?/.match(data)[2]
- new_value = convert_days_to_minutes(value.to_f, hours_in_day)
- filter.data = filter.data.sub("c#{index}_val=#{value}", "c#{index}_val=#{new_value}")
+ # Update filter value when it's before a '|' or at the end of the string
+ value = /c#{index}_val=((.+?)(\||\z))?/.match(data)[2]
+ if value
+ new_value = convert_days_to_minutes(value.to_f, hours_in_day)
+ filter.data = filter.data.sub("c#{index}_val=#{value}", "c#{index}_val=#{new_value}")
+ end
end
filter.save!
end