Skip to content
This repository was archived by the owner on Oct 27, 2022. It is now read-only.

Commit 031d25e

Browse files
authored
Merge pull request #1037 from Duke-Translational-Bioinformatics/develop
Merge consistency status db data migrate bug fix to uatest
2 parents df8f1f5 + ebabb49 commit 031d25e

File tree

3 files changed

+34
-26
lines changed

3 files changed

+34
-26
lines changed

lib/tasks/db_data_migrate.rake

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,22 @@ def migrate_nil_consistency_status
7979
storage_provider = StorageProvider.first
8080
updated_projects = 0
8181
updated_uploads = 0
82-
Project.where(is_consistent: nil).each do |p|
83-
unless p.is_deleted
84-
if storage_provider.get_container_meta(p.id)
85-
p.update_columns(is_consistent: true)
86-
else
87-
p.update_columns(is_consistent: false)
88-
end
89-
updated_projects += 1
82+
projects = Project.where(is_consistent: nil).where.not(is_deleted: true)
83+
puts "#{projects.count} projects with nil consistency_status."
84+
projects.each do |p|
85+
if storage_provider.get_container_meta(p.id)
86+
p.update_columns(is_consistent: true)
87+
else
88+
p.update_columns(is_consistent: false)
9089
end
90+
print '.'
91+
updated_projects += 1
9192
end
93+
puts "#{updated_projects} projects updated."
9294

93-
Upload.where(is_consistent: nil).each do |u|
95+
uploads = Upload.where(is_consistent: nil)
96+
puts "#{uploads.count} uploads with nil consistency_status."
97+
uploads.each do |u|
9498
begin
9599
if storage_provider.get_object_metadata(u.project.id, u.id)
96100
u.update_columns(is_consistent: true)
@@ -99,8 +103,9 @@ def migrate_nil_consistency_status
99103
u.update_columns(is_consistent: false)
100104
end
101105
updated_uploads += 1
106+
print '.'
102107
end
103-
$stderr.print "#{updated_projects} projects and #{updated_uploads} uploads updated consistency"
108+
puts "#{updated_uploads} uploads updated."
104109
end
105110

106111
namespace :db do

spec/cassettes/db_data_migrate/_invoke/consistency_migrations/project/behaves_like_a_consistency_migration/record_is_consistent/should_update_is_consistent_to_true.yml renamed to spec/cassettes/db_data_migrate/_invoke/consistency_migration/for_project/with_deleted_project/1_2_4_1_2_1.yml

Lines changed: 14 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/lib/tasks/db_data_migrate_rake_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@
133133
expect(storage_provider.get_container_meta(record.id)).not_to be_nil
134134
}
135135
it_behaves_like 'a consistency migration', :init_project_storage
136+
137+
context 'with deleted project' do
138+
before(:each) { FactoryGirl.create(:project, :deleted, is_consistent: nil) }
139+
it { expect {invoke_task}.not_to change{Project.where(is_consistent: nil).count} }
140+
end
136141
end
137142

138143
context 'for upload' do

0 commit comments

Comments
 (0)