INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('362');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('363');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('370');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('379');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('380');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('381');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('382');
def self.delete_rule(rule_key)
rule=Rule.find(:first, :conditions => {:plugin_name => 'checkstyle', :plugin_rule_key => rule_key})
if rule
- say_with_time "Deleting Checkstyle rule #{rule_key}..." do
+ say_with_time "Delete Checkstyle rule #{rule_key}..." do
rule_id=rule.id
ActiveRule.destroy_all(["rule_id=?", rule_id])
rule.destroy
def self.delete_snapshots(snapshots)
if snapshots.size>0
- say_with_time "Deleting #{snapshots.size} orphan snapshots..." do
+ say_with_time "Delete #{snapshots.size} orphan snapshots..." do
sids=snapshots.map{|s| s.id}
page_size=100
page_count=(sids.size/page_size)
deprecated_measures=ProjectMeasure.find_by_sql("select p1.* from project_measures p1 where p1.snapshot_id is null and p1.measure_date is not null and not exists(select id from project_measures p2 where p2.project_id=p1.project_id and p2.metric_id=p1.metric_id and p2.measure_date is not null and p2.measure_date>p1.measure_date)")
- say_with_time "Moving #{deprecated_measures.size} measures" do
+ say_with_time "Move #{deprecated_measures.size} measures" do
deprecated_measures.each do |dm|
if dm.project_id
ManualMeasure.create(
projects = Project.find(:all, :select => 'id', :conditions => {:enabled => true, :scope => 'PRJ'})
- say_with_time "Indexing #{projects.size} projects" do
+ say_with_time "Index #{projects.size} projects" do
projects.each do |project|
Java::OrgSonarServerUi::JRubyFacade.getInstance().indexResource(project.id)
end
def self.up
projects=Project.find(:all, :conditions => ['profile_id is not null and copy_resource_id is null'])
- say_with_time "Processing #{projects.size} projects..." do
+ say_with_time "Process #{projects.size} projects..." do
projects.each do |project|
profile = Profile.find(:first, :conditions => ['id=?', project.profile_id])
if profile
def self.up
old_filters = OldFilter.find(:all)
- say_with_time "Moving #{old_filters.size} measure filters" do
+ say_with_time "Move #{old_filters.size} measure filters" do
old_filters.each do |old_filter|
move(old_filter)
end
def self.up
widgets = Widget.find(:all, :conditions => ["widget_key='filter'"])
- say_with_time "Updading #{widgets.size} widgets" do
+ say_with_time "Update #{widgets.size} widgets" do
widgets.each do |widget|
dashboard = Dashboard.find_by_id(widget.dashboard_id)
widget_property = WidgetProperty.find(:first, :conditions => {:widget_id => widget.id, :kee => 'filter'})
--- /dev/null
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2013 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# SonarQube is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+
+#
+# Sonar 3.6
+#
+class PurgeViolations < ActiveRecord::Migration
+
+ class RuleFailure < ActiveRecord::Base
+ end
+
+ def self.up
+ violation_ids = ActiveRecord::Base.connection.select_rows('select rf.id from rule_failures rf inner join snapshots s on rf.snapshot_id=s.id where s.islast=' + ActiveRecord::Base.connection.quoted_false)
+ say_with_time "Purge #{violation_ids.size} violations" do
+ violation_ids.each_slice(999) do |ids|
+ RuleFailure.delete(ids.flatten) if ids.size>0
+ end
+ end
+ end
+
+end
+
def self.up
duplicated_ids = ActiveRecord::Base.connection.select_rows('select rule_failure_permanent_id from reviews group by rule_failure_permanent_id having count(*) > 1')
- say_with_time "Removing #{duplicated_ids.size} duplicated reviews" do
+ say_with_time "Remove #{duplicated_ids.size} duplicated reviews" do
duplicated_ids.each do |id|
reviews = Review.find(:all, :conditions => {:rule_failure_permanent_id => id})
# delete all reviews except the last one
one_year_ago = Time.now.years_ago(1)
- say_with_time "Converting #{violation_ids.size} violations to issues" do
+ say_with_time "Convert #{violation_ids.size} violations to issues" do
logins_by_id = User.all.inject({}) do |result, user|
result[user.id]=user.login
result
from rule_failures rf
inner join snapshots s on s.id=rf.snapshot_id
left join reviews rev on rev.rule_failure_permanent_id=rf.permanent_id
- where rf.id in (#{ids.join(',')})"
+ where rf.id in (#{ids.flatten.join(',')})"
end
def self.new_key