Sha256: 782c524b9113431edbd2b5400448bab6f011e03fd3885dbc3fafc8625287430d
Contents?: true
Size: 1.07 KB
Versions: 8
Compression:
Stored size: 1.07 KB
Contents
module StudyEngine class StudyID class Bank < ActiveRecord::Base self.table_name = "study_engine_study_ids" 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 def self.studies pluck(:study_id_study).uniq.sort end def self.sites pluck(:study_id_site).uniq.sort end 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 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 validates :study_id_study, :study_id_site, format: /\A[A-Z]{3}\Z/ validates :study_id_id, format: /\A[0-9]{4}\Z/ end end end
Version data entries
8 entries across 8 versions & 1 rubygems