<commit_before>class Listing < ActiveRecord::Base
  belongs_to :creator, class_name: "User", foreign_key: "user_id"
  has_many :followed_listings, dependent: :destroy
  has_many :followers, through: :followed_listings
  has_many :listings_categories, dependent: :destroy
  has_many :categories, through: :listings_categories
  has_many :donation_applications, dependent: :destroy
  has_many :applicants, through: :donation_applications

  def get_show_image
    self.image_url || 'http://placehold.it/400x300&text=[img]'
  end

  def self.import(file)
    CSV.foreach(file.path, headers: true) do |row|
      logger.debug "ROW: #{row}"
      listing = find_by_id(row['id']) || new
      listing.attributes = row.to_hash
      logger.debug "LISTING: #{listing}"
      listing.save!
    end
  end

  def requires_pdf_form?
    # !self.pdf.nil?
    self.creator.entity_name == "Sacramento County"
  end
end
<commit_msg>Fix bug in Listing importer required headers<commit_after>class Listing < ActiveRecord::Base
  belongs_to :creator, class_name: "User", foreign_key: "user_id"
  has_many :followed_listings, dependent: :destroy
  has_many :followers, through: :followed_listings
  has_many :listings_categories, dependent: :destroy
  has_many :categories, through: :listings_categories
  has_many :donation_applications, dependent: :destroy
  has_many :applicants, through: :donation_applications

  validates_presence_of :title, :creator

  def get_show_image
    self.image_url || 'http://placehold.it/400x300&text=[img]'
  end

  def requires_pdf_form?
    # !self.pdf.nil?
    self.creator.entity_name == "Sacramento County"
  end
end

{'fraction_non_alphanumeric': 0.10507025045815516, 'fraction_numerical': 0.007330482590103849, 'mean_word_length': 4.892086330935252, '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': '6471863', 'n_tokens_mistral': 563, 'n_tokens_neox': 543, 'n_words': 122}