<commit_before>class LegacyProject < ActiveRecord::Base
  include LegacyBase
  establish_connection "legacy"

  image_accessor :cover

  self.table_name = "projects"
  # self.primary_key = "old_id"

  # To use autogenerated ids uncomment below
  def dont_migrate_ids
    false
  end

  def migrate_where
    {id: self.id}
  end

  def map
    {
      state: get_state,
      name: self.name,
      user_id: self.user_id,
      category_id: self.category_id,
      goal: self.goal,
      about: self.about,
      headline: self.headline,
      video_url: self.video_url,
      short_url: self.short_url,
      created_at: self.created_at,
      updated_at: self.updated_at,
      about_html: self.about_html,
      recommended: self.recommended,
      home_page_comment: self.home_page_comment,
      permalink: self.permalink.gsub!(/\s+/, ''),
      online_days: get_online_days,
      online_date: get_online_date,
      #how_know: text,
      #more_links: text,
      #first_backers: text,
      remote_uploaded_image_url: get_image_url,
      budget: self.budget,
      budget_html: self.budget_html,
      terms: self.terms,
      terms_html: self.terms_html,
      site: self.site,
      hash_tag: self.hash_tag,
      address_city: self.address_city,
      address_state: self.address_state,
      address_zip_code: self.address_zip_code,
      address_neighborhood: self.address_neighborhood,
      foundation_widget: self.foundation_widget,
      campaign_type: self.project_type,
      featured: self.home_page
    }
  end

  def get_online_date
    self.created_at if self.visible?
  end

  def get_online_days
    ((self.expires_at - self.created_at).abs/60/60/24).round
  end

  def get_image_url
    if self.cover.present?
      return self.cover.remote_url(expires: 1.day.from_now)
    elsif self.image_url.present?
      return self.image_url
    end
  end


  def get_state
    state = 'draft'
    if self.finished

      # Successful
      state = 'successful' if self.successful? and expired?

    elsif self.visible?
      state = 'online'
    end

    state = 'rejected' if self.rejected == true
    state = 'soon' if self.soon == true and self.visible?
    state
  end<commit_msg>Only set online date if project is not soon and is visible<commit_after>class LegacyProject < ActiveRecord::Base
  include LegacyBase
  establish_connection "legacy"

  image_accessor :cover

  self.table_name = "projects"
  # self.primary_key = "old_id"

  # To use autogenerated ids uncomment below
  def dont_migrate_ids
    false
  end

  def migrate_where
    {id: self.id}
  end

  def map
    {
      state: get_state,
      name: self.name,
      user_id: self.user_id,
      category_id: self.category_id,
      goal: self.goal,
      about: self.about,
      headline: self.headline,
      video_url: self.video_url,
      short_url: self.short_url,
      created_at: self.created_at,
      updated_at: self.updated_at,
      about_html: self.about_html,
      recommended: self.recommended,
      home_page_comment: self.home_page_comment,
      permalink: self.permalink.gsub!(/\s+/, ''),
      online_days: get_online_days,
      online_date: get_online_date,
      #how_know: text,
      #more_links: text,
      #first_backers: text,
      remote_uploaded_image_url: get_image_url,
      budget: self.budget,
      budget_html: self.budget_html,
      terms: self.terms,
      terms_html: self.terms_html,
      site: self.site,
      hash_tag: self.hash_tag,
      address_city: self.address_city,
      address_state: self.address_state,
      address_zip_code: self.address_zip_code,
      address_neighborhood: self.address_neighborhood,
      foundation_widget: self.foundation_widget,
      campaign_type: self.project_type,
      featured: self.home_page
    }
  end

  def get_online_date
    self.created_at if self.visible?
  end

  def get_online_days
    ((self.expires_at - self.created_at).abs/60/60/24).round if not self.soon and self.visible
  end

  def get_image_url
    if self.cover.present?
      return self.cover.remote_url(expires: 1.day.from_now)
    elsif self.image_url.present?
      return self.image_url
    end
  end


  def get_state
    state = 'draft'
    if self.finished

      # Successful
      state = 'successful' if self.successful? and expired?

    elsif self.visible?
      state = 'online'
    end

    state = 'rejected' if self.rejected == true
    state = 'soon' if self.soon == true and self.visible?
    state
  end
{'fraction_non_alphanumeric': 0.08614148627538495, 'fraction_numerical': 0.003124302611024325, 'mean_word_length': 2.7950889077053342, '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': '2617195', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1500, 'n_words': 325}