<commit_before>class HrSiApplication < ActiveRecord::Base
  unloadable
  set_table_name        "hr_si_applications"
  set_primary_key       "applicationID"
  
  belongs_to :apply
  belongs_to :person, :foreign_key => "fk_personID"
  has_one    :sitrack_tracking, :foreign_key => 'application_id'
  has_one    :sitrack_mpd, :foreign_key => 'application_id'
  has_many   :sitrack_salary_forms
  belongs_to :location_a, :foreign_key => "locationA", :class_name => "HrSiProject" 
  belongs_to :location_b, :foreign_key => "locationB", :class_name => "HrSiProject" 
  belongs_to :location_c, :foreign_key => "locationC", :class_name => "HrSiProject" 
  
  before_create :create_apply
  before_save :stamp
  
  YEAR = 2010
  APPLICATION_SLEEVE_SLUG = "stint_internship" # this is set when creating a new sleeve

  #set dateChanged and changedBy
  def stamp
    self.dateAppLastChanged = Time.now
  end

  def self.is_intern(type)
    return true if 'Internship' == type || 'Class B Intern' == type
    return false
  end

  def find_or_create_apply()
    if self.apply.nil?
      create_apply
    end
    self.apply
  end
  
protected
  def sleeve
    @@sleeve ||= Sleeve.find_by_slug(APPLICATION_SLEEVE_SLUG)
    if @@sleeve.nil?
      raise "No STINT/Internship questionnaire found to match slug '#{APPLICATION_SLEEVE_SLUG}'"
    end
    @@sleeve
  end

  def create_apply
    self.dateAppStarted = Time.now
    self.apply = Apply.create(:sleeve_id => self.sleeve.id, :applicant_id => self.person.personID)
  end
end<commit_msg>don't create an apply record if we already have one<commit_after>class HrSiApplication < ActiveRecord::Base
  unloadable
  set_table_name        "hr_si_applications"
  set_primary_key       "applicationID"
  
  belongs_to :apply
  belongs_to :person, :foreign_key => "fk_personID"
  has_one    :sitrack_tracking, :foreign_key => 'application_id'
  has_one    :sitrack_mpd, :foreign_key => 'application_id'
  has_many   :sitrack_salary_forms
  belongs_to :location_a, :foreign_key => "locationA", :class_name => "HrSiProject" 
  belongs_to :location_b, :foreign_key => "locationB", :class_name => "HrSiProject" 
  belongs_to :location_c, :foreign_key => "locationC", :class_name => "HrSiProject" 
  
  before_create :create_apply
  before_save :stamp
  
  YEAR = 2010
  APPLICATION_SLEEVE_SLUG = "stint_internship" # this is set when creating a new sleeve

  #set dateChanged and changedBy
  def stamp
    self.dateAppLastChanged = Time.now
  end

  def self.is_intern(type)
    return true if 'Internship' == type || 'Class B Intern' == type
    return false
  end

  def find_or_create_apply()
    if self.apply.nil?
      create_apply
    end
    self.apply
  end
  
protected
  def sleeve
    @@sleeve ||= Sleeve.find_by_slug(APPLICATION_SLEEVE_SLUG)
    if @@sleeve.nil?
      raise "No STINT/Internship questionnaire found to match slug '#{APPLICATION_SLEEVE_SLUG}'"
    end
    @@sleeve
  end

  def create_apply
    self.dateAppStarted = Time.now
    self.apply ||= Apply.create(:sleeve_id => self.sleeve.id, :applicant_id => self.person.personID)
  end
end
{'fraction_non_alphanumeric': 0.0935880829015544, 'fraction_numerical': 0.0025906735751295338, 'mean_word_length': 3.9187898089171975, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '2951891', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1091, 'n_words': 246}