Class: StudyEngine::StudyID::Bank
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- StudyEngine::StudyID::Bank
- Defined in:
- app/models/study_engine/study_id/bank.rb
Class Method Summary collapse
- .find_or_create_from_full_study_id(study_id) ⇒ Object
- .ids_grouped_by_study_and_site ⇒ Object
- .sites ⇒ Object
- .studies ⇒ Object
- .studies_grouped_by_site ⇒ Object
Class Method Details
.find_or_create_from_full_study_id(study_id) ⇒ Object
6 7 8 9 |
# File 'app/models/study_engine/study_id/bank.rb', line 6 def self.find_or_create_from_full_study_id study_id study_id_study, study_id_site, study_id_id = study_id.split("-") find_or_create_by study_id_study: study_id_study, study_id_site: study_id_site, study_id_id: study_id_id end |
.ids_grouped_by_study_and_site ⇒ Object
19 20 21 22 23 24 |
# File 'app/models/study_engine/study_id/bank.rb', line 19 def self.ids_grouped_by_study_and_site all.reduce(Hash.new([])) do |hash, study_id| hash[study_id.study_id_study + study_id.study_id_site] += [study_id.study_id_id] hash end end |
.sites ⇒ Object
15 16 17 |
# File 'app/models/study_engine/study_id/bank.rb', line 15 def self.sites pluck(:study_id_site).uniq.sort end |
.studies ⇒ Object
11 12 13 |
# File 'app/models/study_engine/study_id/bank.rb', line 11 def self.studies pluck(:study_id_study).uniq.sort end |
.studies_grouped_by_site ⇒ Object
26 27 28 29 30 31 |
# File 'app/models/study_engine/study_id/bank.rb', line 26 def self.studies_grouped_by_site all.reduce(Hash.new(Set.new)) do |hash, study_id| hash[study_id.study_id_site] += [study_id.study_id_study] hash end end |