Skip to content

Commit

Permalink
Added method remove_all_data to the StudyRelationship class inorder t…
Browse files Browse the repository at this point in the history
…o delete all the data from study models.
  • Loading branch information
Javier-Jimenez-18 committed Oct 6, 2023
1 parent e376ab3 commit a2f4229
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/models/study_relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ def self.study_models
@models = (connection.tables - blacklist).map{|k| k.singularize.camelize.constantize }
end

def self.remove_all_data
study_models.each do |model|
model.delete_all
end
end

def self.create_nct_indexes
blacklist = %w(
ar_internal_metadata
Expand Down
2 changes: 1 addition & 1 deletion spec/models/utils/util_table_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# this study has new line chars embedded in Outcomes.description. Will verify they don't cause probs in flat files
db = Util::DbManager.new
db.remove_indexes_and_constraints
Study.destroy_all
StudyRelationship.remove_all_data
record = StudyJsonRecord.create(nct_id: 'NCT05594173', content: JSON.parse(File.read('spec/support/json_data/NCT05594173.json')))
record.create_or_update_study
db.add_indexes
Expand Down

0 comments on commit a2f4229

Please sign in to comment.