lib/ensembl/variation/activerecord.rb in ensembl-0.0.7 vs lib/ensembl/variation/activerecord.rb in ensembl-0.0.9

- old
+ new

@@ -1,12 +1,17 @@ require 'active_record' module Ensembl module Variation + + # ConnectionPool implemented from: + # http://www.lucasallan.com/2014/05/26/fixing-concurrency-issues-with-active-record-in-a-rack-application.html class Connection < ActiveRecord::Base - self.extend TableNameOverrides + self.extend Ensembl::TableNameOverrides + self.extend Ensembl::ConnectionPool + self.abstract_class = true self.establish_connection :variation end @@ -232,19 +237,21 @@ belongs_to :phenotype belongs_to :source belongs_to :study belongs_to :seq_region, class_name: 'Ensembl::Core::SeqRegion' + has_one :variation, primary_key: 'object_id', foreign_key: 'name' + has_many :phenotype_feature_attribs has_many :attrib_types, through: :phenotype_feature_attribs scope :significant, -> { where(is_significant: true )} scope :with_studies, -> { where.not(study_id:nil)} - def variation - Variation.find_by name: object_id - end + # def variation + # Variation.find_by name: object_id + # end def risk_allele pf=phenotype_feature_attribs.risk_alleles.first pf.value unless pf.nil? end @@ -487,10 +494,10 @@ def phenotype_features PhenotypeFeature.eager_load(:phenotype).where(object_id_column: name, type: 'Variation') end def all_phenotype_features - object_ids = synonyms + object_ids = synonym_names object_ids<<name PhenotypeFeature.eager_load(:phenotype).where(object_id: object_ids, type: 'Variation') end # Made because of the need to cut down database queries \ No newline at end of file