<commit_before>class Embeddable::DataCollector < Embeddable::Embeddable
  set_table_name "embeddable_data_collectors"

  # belongs_to :user
  belongs_to :probe_type, :class_name => 'Probe::ProbeType'
  belongs_to :calibration, :class_name => 'Probe::Calibration'
  
  # has_many :page_elements, :as => :embeddable
  # has_many :pages, :through =>:page_elements
  # has_many :teacher_notes, :as => :authored_entity
  
  belongs_to :prediction_graph_source,
    :class_name => "Embeddable::DataCollector",
    :foreign_key => "prediction_graph_id"

  has_many :prediction_graph_destinations,
    :class_name => "Embeddable::DataCollector",
    :foreign_key => "prediction_graph_id"

  # this could work if the finder sql was redone
  # has_many :investigations,
  #   :finder_sql => 'SELECT embeddable_data_collectors.* FROM embeddable_data_collectors
  #   INNER JOIN page_elements ON embeddable_data_collectors.id = page_elements.embeddable_id AND page_elements.embeddable_type = "Embeddable::DataCollector"
  #   INNER JOIN pages ON page_elements.page_id = pages.id
  #   WHERE pages.section_id = #{id}'

  serialize :data_store_values
  
  # def before_save
  #   self.name = self.title
  # end
  
  # acts_as_replicatable
  
  # send_update_events_to :investigation
  # 
  # include Changeable
  # 
  # include Cloneable
  @@cloneable_associations = [:prediction_graph_destinations]
  
  # self.extend SearchableModel
  
  @@searchable_attributes = %w{uuid name description title x_axis_label x_axis_units y_axis_label y_axis_units}
  
  class <<self
    def searchable_attributes
      @@searchable_attributes
    end
    def cloneable_associations
      @@cloneable_associations
    end
  end
  
  def other_data_collectors_in_activity_scope(scope)
    if scope && scope.class != Embeddable::DataCollector
      scope.activity.data_collectors - [self]
    else
      []
    end
  end
  
  def self.by_scope(scope)
    if scope && scope.class != Embeddable::DataCollector
      scope.activity.investigation.data_collectors
    else<commit_msg>revert DataCollector inheritance from abstract model<commit_after>class Embeddable::DataCollector < ActiveRecord::Base
  set_table_name "embeddable_data_collectors"

  belongs_to :user
  belongs_to :probe_type, :class_name => 'Probe::ProbeType'
  belongs_to :calibration, :class_name => 'Probe::Calibration'
  
  has_many :page_elements, :as => :embeddable
  has_many :pages, :through =>:page_elements
  has_many :teacher_notes, :as => :authored_entity
  
  belongs_to :prediction_graph_source,
    :class_name => "Embeddable::DataCollector",
    :foreign_key => "prediction_graph_id"

  has_many :prediction_graph_destinations,
    :class_name => "Embeddable::DataCollector",
    :foreign_key => "prediction_graph_id"

  # this could work if the finder sql was redone
  # has_many :investigations,
  #   :finder_sql => 'SELECT embeddable_data_collectors.* FROM embeddable_data_collectors
  #   INNER JOIN page_elements ON embeddable_data_collectors.id = page_elements.embeddable_id AND page_elements.embeddable_type = "Embeddable::DataCollector"
  #   INNER JOIN pages ON page_elements.page_id = pages.id
  #   WHERE pages.section_id = #{id}'

  serialize :data_store_values
  
  def before_save
    self.name = self.title
  end
  
  acts_as_replicatable
  
  send_update_events_to :investigations
  
  def investigations
    invs = []
    self.pages.each do |page|
      inv = page.investigation
      invs << inv if inv
    end
  end

  include Changeable
  
  include Cloneable
  @@cloneable_associations = [:prediction_graph_destinations]
  
  self.extend SearchableModel
  
  @@searchable_attributes = %w{uuid name description title x_axis_label x_axis_units y_axis_label y_axis_units}
  
  class <<self
    def searchable_attributes
      @@searchable_attributes
    end
    def cloneable_associations
      @@cloneable_associations
    end
  end
  
  def other_data_collectors_in_activity_scope(scope)
    if scope && scope.class != Embeddable::DataCollector
      scope.activity.data_collectors - [self]
    else
      []
    end
  end
  
  def self.by_scope(scope)
    if scope && scope.class != Embeddable::DataCollector
      scope.activity.investigation.data_collectors
    else
{'fraction_non_alphanumeric': 0.08235016517225106, 'fraction_numerical': 0.0, 'mean_word_length': 4.220443349753695, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, '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': '1443981', 'n_tokens_mistral': 1445, 'n_tokens_neox': 1404, 'n_words': 278}