<commit_before>module IsAnEntityImportedFromFeeds
  extend ActiveSupport::Concern

  included do
    has_many :entities_imported_from_feed, as: :entity
    has_many :imported_from_feeds, through: :entities_imported_from_feed, source: :feed
    has_many :imported_from_feed_versions, through: :entities_imported_from_feed, source: :feed_version
  end

  def imported_from_feed=(imported_from_feed_params)
    params = HashHelpers::update_keys(imported_from_feed_params, :underscore)
    feed = params[:feed] || Feed.find_by!(onestop_id: params[:onestop_id])
    if params[:sha1].present?
      feed_version = params[:feed_version] || feed.feed_versions.find_by!(sha1: params[:sha1])
    end
    self.entities_imported_from_feed.find_or_initialize_by(feed: feed, feed_version: feed_version)
  end
end<commit_msg>read imported_from_feed<commit_after>module IsAnEntityImportedFromFeeds
  extend ActiveSupport::Concern

  included do
    has_many :entities_imported_from_feed, as: :entity
    has_many :imported_from_feeds, through: :entities_imported_from_feed, source: :feed
    has_many :imported_from_feed_versions, through: :entities_imported_from_feed, source: :feed_version
  end

  def imported_from_feed
    nil
  end

  def imported_from_feed=(imported_from_feed_params)
    params = HashHelpers::update_keys(imported_from_feed_params, :underscore)
    feed = params[:feed] || Feed.find_by!(onestop_id: params[:onestop_id])
    if params[:sha1].present?
      feed_version = params[:feed_version] || feed.feed_versions.find_by!(sha1: params[:sha1])
    end
    self.entities_imported_from_feed.find_or_initialize_by(feed: feed, feed_version: feed_version)
  end
end
{'fraction_non_alphanumeric': 0.08862275449101796, 'fraction_numerical': 0.003592814371257485, 'mean_word_length': 6.426666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?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': '673379', 'n_tokens_mistral': 565, 'n_tokens_neox': 563, 'n_words': 94}