diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-01-04 15:52:43 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-01-04 15:52:43 +0000 |
commit | 32de21d20578c3202141cd1965a8f3d53c8ba786 (patch) | |
tree | e36b54bb010d2338cf59fb920227701abdc5e16f /sonar-server | |
parent | 55eda8f84f3a524fcabc8418c2573af464b15015 (diff) | |
download | sonarqube-32de21d20578c3202141cd1965a8f3d53c8ba786.tar.gz sonarqube-32de21d20578c3202141cd1965a8f3d53c8ba786.zip |
fix migration to delete unvalid snapshots generated in sonar <= 2.3
Diffstat (limited to 'sonar-server')
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/db/migrate/170_delete_unvalid_project_snapshots.rb (renamed from sonar-server/src/main/webapp/WEB-INF/db/migrate/152_delete_duplicated_lib_snapshots.rb) | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/152_delete_duplicated_lib_snapshots.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/170_delete_unvalid_project_snapshots.rb index f9906e36a8f..623f1c8087f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/152_delete_duplicated_lib_snapshots.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/170_delete_unvalid_project_snapshots.rb @@ -19,9 +19,10 @@ # # -# Sonar 2.4 +# Sonar 2.5 # -class DeleteDuplicatedLibSnapshots < ActiveRecord::Migration +class DeleteUnvalidProjectSnapshots < ActiveRecord::Migration + def self.up metric=Metric.find(:first, :conditions => ['name=?','lines']) if metric @@ -31,25 +32,15 @@ class DeleteDuplicatedLibSnapshots < ActiveRecord::Migration end def self.select_snapshots_without_measures(metric) - snapshots=[] + snapshots=nil say_with_time "Select project snapshots without measures..." do - snapshots=Snapshot.find_by_sql ["SELECT s.id FROM snapshots s WHERE s.scope='PRJ' and s.qualifier IN ('TRK', 'BRC') AND status='P' AND NOT EXISTS (select m.id from project_measures m WHERE m.snapshot_id=s.id AND m.metric_id=?) and not exists(select * from dependencies d where d.to_snapshot_id=s.id)", metric.id] + snapshots=Snapshot.find_by_sql ["SELECT s.id FROM snapshots s WHERE s.scope='PRJ' and s.qualifier IN ('TRK', 'BRC') AND status='P' AND islast=? AND NOT EXISTS (select m.id from project_measures m WHERE m.snapshot_id=s.id AND m.metric_id=?)", false, metric.id] end snapshots end - def self.filter_involved_in_dependencies(snapshots) - result=[] - if snapshots.size>0 - say_with_time "Filter #{snapshots.size} snapshots..." do - result=Snapshot.find_by_sql ["SELECT s.id FROM snapshots s where s.id in (?) and not exists(select * from dependencies d where d.to_snapshot_id=s.id", snapshots.map{|s| s.id}] - end - end - return result - end - def self.delete_snapshots(snapshots) - if snapshots.size > 0 + if snapshots.size>0 say_with_time "Deleting #{snapshots.size} orphan snapshots..." do sids=snapshots.map{|s| s.id} page_size=100 |