<commit_before>module LogrageParams
  module Controller
    def append_info_to_payload(payload)
      super

      payload[:params] = request.params
      devise_users = methods.grep(/^current_/).each_with_object({}) do |m, hsh|
        user_type = m.to_s.gsub(/^current_/, '')
        u = send(m)
        hsh[user_type] = u if u
      end
      payload[:browser] = request.user_agent

      payload[:users] = {}
      if devise_users.empty?
        payload[:users][:user] = "None"
      else
        devise_users.each do |type, user|
          payload[:users][type] = user.id
        end
      end
    end
  end
end
<commit_msg>Fixing bug in logging<commit_after>module LogrageParams
  module Controller
    def append_info_to_payload(payload)
      super

      payload[:params] = request.params
      devise_users = methods.grep(/^current_/).each_with_object({}) do |m, hsh|
        user_type = m.to_s.gsub(/^current_/, '')
        u = send(m)
        hsh[user_type] = u if u && u.respond_to?(:id)
      end
      payload[:browser] = request.user_agent

      payload[:users] = {}
      if devise_users.empty?
        payload[:users][:user] = "None"
      else
        devise_users.each do |type, user|
          payload[:users][type] = user.id
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.12189440993788819, 'fraction_numerical': 0.0, 'mean_word_length': 2.296675191815857, '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': '6937851', 'n_tokens_mistral': 427, 'n_tokens_neox': 420, 'n_words': 88}