<commit_before>class Variant < ActiveRecord::Base
  belongs_to :gene, inverse_of: :variants
  belongs_to :location, inverse_of: :variants
  belongs_to :amino_acid, inverse_of: :variants
  belongs_to :variant_type, inverse_of: :variants
  belongs_to :mutation_type, inverse_of: :variants
  belongs_to :transcript, inverse_of: :variants
  belongs_to :version, inverse_of: :variants
  belongs_to :batch, inverse_of: :variants
  has_many :disease_source_variants
  has_many :disease_sources, through: :disease_source_variants, source: :source
  has_many :diseases, through: :disease_source_variants
  has_many :drug_interactions
  has_many :drug_sources, through: :drug_interactions, source: :source
  has_and_belongs_to_many :tags

  serialize :meta, JSON

  def self.index_scope
    eager_load(:location, :gene, :amino_acid, :diseases, :disease_sources, :mutation_type, :variant_type, :tags, :version, :batch)
  end

  def self.show_scope
    eager_load(:location, :gene, :variant_type, :amino_acid, :mutation_type, :drug_interactions, :transcript, :version, :batch, :tags, disease_source_variants: [:disease, :source], drug_interactions: [:source])
  end

  def is_indel?
    ['INS', 'DEL'].include?(variant_type.name)
  end

  def from_tim_ley?
    !tim_ley_annotation.blank?
  end
end
<commit_msg>fix eager loading to use correct relations<commit_after>class Variant < ActiveRecord::Base
  belongs_to :gene, inverse_of: :variants
  belongs_to :location, inverse_of: :variants
  belongs_to :amino_acid, inverse_of: :variants
  belongs_to :variant_type, inverse_of: :variants
  belongs_to :mutation_type, inverse_of: :variants
  belongs_to :transcript, inverse_of: :variants
  belongs_to :batch, inverse_of: :variants
  has_many :disease_source_variants
  has_many :diseases, through: :disease_source_variants
  has_many :disease_sources, through: :disease_source_variants, source: :source
  has_many :drug_interactions
  has_many :drug_sources, through: :drug_interactions, source: :source

  def self.index_scope
    eager_load(:location, :gene, :amino_acid, :mutation_type, :variant_type, disease_source_variants: [:version, :tags, :source, :disease])
  end

  def self.show_scope
    eager_load(:location, :gene, :variant_type, :amino_acid, :mutation_type, :drug_interactions, :transcript, :version, :batch, :tags, disease_source_variants: [:disease, :source], drug_interactions: [:source])
  end

  def is_indel?
    ['INS', 'DEL'].include?(variant_type.name)
  end
end

{'fraction_non_alphanumeric': 0.10428455941794665, 'fraction_numerical': 0.0, 'mean_word_length': 6.615384615384615, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2842335', 'n_tokens_mistral': 894, 'n_tokens_neox': 861, 'n_words': 195}