<commit_before>class Gws::Elasticsearch::Indexer::ShareFileJob < Gws::ApplicationJob
  include Gws::Elasticsearch::Indexer::Base

  self.model = Gws::Share::File

  private

  def index_type
    'gws_share_files'
  end

  def enum_es_docs
    Enumerator.new do |y|
      doc = {}
      if item.folder.present?
        doc[:url] = url_helpers.gws_share_folder_file_path(site: self.site, folder: item.folder, id: item)
      else
        doc[:url] = url_helpers.gws_share_file_path(site: self.site, id: item)
      end
      doc[:name] = item.name
      doc[:categories] = item.categories.pluck(:name)
      doc[:data] = Base64.strict_encode64(::File.binread(item.path))
      doc[:file] = {}
      doc[:file][:extname] = item.extname.upcase
      doc[:file][:size] = item.size

      # doc[:release_date] = topic.release_date.try(:iso8601)
      # doc[:close_date] = topic.close_date.try(:iso8601)
      # doc[:released] = topic.released.try(:iso8601)
      # doc[:state] = post.state
      doc[:state] = 'public'

      doc[:user_name] = item.user.long_name if item.user.present?
      doc[:group_ids] = item.groups.pluck(:id)
      doc[:custom_group_ids] = item.custom_groups.pluck(:id)
      doc[:user_ids] = item.users.pluck(:id)
      doc[:permission_level] = item.permission_level

      doc[:readable_group_ids] = item.readable_groups.pluck(:id)
      doc[:readable_custom_group_ids] = item.readable_custom_groups.pluck(:id)
      doc[:readable_member_ids] = item.readable_members.pluck(:id)

      doc[:updated] = item.updated.try(:iso8601)
      doc[:created] = item.created.try(:iso8601)

      y << [ "file-#{item.id}", doc ]
    end
  end
end<commit_msg>[modify] w/ rubocop C: Assignment Branch Condition size for enum_es_docs is too high.<commit_after>class Gws::Elasticsearch::Indexer::ShareFileJob < Gws::ApplicationJob
  include Gws::Elasticsearch::Indexer::Base

  self.model = Gws::Share::File

  private

  def index_type
    'gws_share_files'
  end

  def enum_es_docs
    Enumerator.new do |y|
      doc = {}
      doc[:url] = item_path
      doc[:name] = item.name
      doc[:categories] = item.categories.pluck(:name)
      doc[:data] = Base64.strict_encode64(::File.binread(item.path))
      doc[:file] = {}
      doc[:file][:extname] = item.extname.upcase
      doc[:file][:size] = item.size

      # doc[:release_date] = topic.release_date.try(:iso8601)
      # doc[:close_date] = topic.close_date.try(:iso8601)
      # doc[:released] = topic.released.try(:iso8601)
      # doc[:state] = post.state
      doc[:state] = 'public'

      doc[:user_name] = item.user.long_name if item.user.present?
      doc[:group_ids] = item.groups.pluck(:id)
      doc[:custom_group_ids] = item.custom_groups.pluck(:id)
      doc[:user_ids] = item.users.pluck(:id)
      doc[:permission_level] = item.permission_level

      doc[:readable_group_ids] = item.readable_groups.pluck(:id)
      doc[:readable_custom_group_ids] = item.readable_custom_groups.pluck(:id)
      doc[:readable_member_ids] = item.readable_members.pluck(:id)

      doc[:updated] = item.updated.try(:iso8601)
      doc[:created] = item.created.try(:iso8601)

      y << [ "file-#{item.id}", doc ]
    end
  end

  def item_path
    if item.folder.present?
      url_helpers.gws_share_folder_file_path(site: self.site, folder: item.folder, id: item)
    else
      url_helpers.gws_share_file_path(site: self.site, id: item)
    end
  end
end
{'fraction_non_alphanumeric': 0.1465340742907283, 'fraction_numerical': 0.014039192746417082, 'mean_word_length': 3.4881889763779528, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5826036', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1194, 'n_words': 180}