]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4305 purge unprocessed violations before migrating to issues
authorSimon Brandhof <simon.brandhof@gmail.com>
Thu, 13 Jun 2013 21:53:05 +0000 (23:53 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Thu, 13 Jun 2013 21:53:56 +0000 (23:53 +0200)
sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
sonar-server/src/main/webapp/WEB-INF/db/migrate/134_delete_checkstyle_translations.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/170_delete_unvalid_project_snapshots.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/212_move_async_measures.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/287_index_projects.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/331_remove_projects_profile_id.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/360_move_existing_measure_filters.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/361_move_filter_widgets.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/379_purge_violations.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/db/migrate/400_delete_review_duplications.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/401_migrate_violations_to_issues.rb

index aaef7a8f8323eda9507720f576573ce360341828..18020cb76a15040c4e1eab0c81cf423fe915999d 100644 (file)
@@ -150,6 +150,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('361');
 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');
index a6c787ced7ab7d6de865e5b2cff1bcb9493901fc..1235fe1603d39c6c40017fa6bc713f666eeb906f 100644 (file)
@@ -39,7 +39,7 @@ class DeleteCheckstyleTranslations < ActiveRecord::Migration
   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
index c9991266c8621905b0c0068c0633fc2c64e5d221..986e6a70fe765789f3128fd151ec4ecc817edd0c 100644 (file)
@@ -42,7 +42,7 @@ class DeleteUnvalidProjectSnapshots < ActiveRecord::Migration
 
   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)
index 3fef397db24aecb650263dfeb9e2538ac624e86c..ccf910114094962c10733e5fd3b7de2c42e7210f 100644 (file)
@@ -35,7 +35,7 @@ class MoveAsyncMeasures < ActiveRecord::Migration
 
     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(
index 7eff6a11ef0ce4c527519e5f3a5b2c499e51ac3d..b972594686a7ac2a2c5be832ee33494e1385d0e3 100644 (file)
@@ -35,7 +35,7 @@ class IndexProjects < ActiveRecord::Migration
 
     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
index f294265eb5178f2f4ad239209d8377bc12db563b..32f94026772092082447d2eb0d3bc04927f97452 100644 (file)
@@ -36,7 +36,7 @@ class RemoveProjectsProfileId < ActiveRecord::Migration
 
   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
index 583131c6bb0eece8cd39054b480e538187a4d578..ca2eccc2044d08962e181354e963d3d3f6add732 100644 (file)
@@ -43,7 +43,7 @@ class MoveExistingMeasureFilters < ActiveRecord::Migration
 
   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
index 1733bc1aa9bb0634d75844ac26c980e3b1bab2f9..0c559eee77ddefcbaaf627fbce5e687412f38c8a 100644 (file)
@@ -41,7 +41,7 @@ class MoveFilterWidgets < ActiveRecord::Migration
 
   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'})
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/379_purge_violations.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/379_purge_violations.rb
new file mode 100644 (file)
index 0000000..6038fe5
--- /dev/null
@@ -0,0 +1,39 @@
+#
+# 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
+
index d6b39a8469bf07baf8548bd18dd66ae52750b30b..da052697b7b19c0735031a44007b9687683c37a2 100644 (file)
@@ -29,7 +29,7 @@ class DeleteReviewDuplications < ActiveRecord::Migration
 
   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
index e13ca9b25b06d55dcd9fa7d8b21c56f7ae68caf9..f3b618c5f26902e1ea3f9704666ed2306c04e8eb 100644 (file)
@@ -48,7 +48,7 @@ class MigrateViolationsToIssues < ActiveRecord::Migration
 
     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
@@ -151,7 +151,7 @@ class MigrateViolationsToIssues < ActiveRecord::Migration
     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