<commit_before>class Scamp
  module Users
    
    # <user>
    #   <id type="integer">1</id>
    #   <name><NAME></name>
    #   <email-address><EMAIL></email-address>
    #   <admin type="boolean">true</admin>
    #   <created-at type="datetime">2009-11-20T16:41:39Z</created-at>
    #   <type>Member</type>
    #   <avatar-url>http://asset0.37img.com/global/.../avatar.png</avatar-url>
    # </user>
    
    # Return the user_id if we haven't got the real name and
    # kick off a user data fetch
    def username_for(user_id)
      return user_cache[user_id]["name"] if user_cache[user_id]
      fetch_data_for(user_id)
      return user_id.to_s
    end
    
    private
    
    def fetch_data_for(user_id)
      url = "https://#{subdomain}.campfirenow.com/users/#{user_id}.json"
      http = EventMachine::HttpRequest.new(url).get(:head => {'authorization' => [api_key, 'X'], "Content-Type" => "application/json"})
      logger.debug http.inspect
      http.callback do
        logger.debug "Got the data for #{user_id}"
        update_user_cache_with(user_id, Yajl::Parser.parse(http.response)['user'])
      end
      http.errback do
        logger.error "Couldn't fetch user data for #{user_id} with url #{url}\n#{http.response_header.status.inspect}\n#{http.response_header.inspect}\n#{http.response.inspect}"
      end
    end
    
    def update_user_cache_with(user_id, data)
      logger.debug "Updated user cache for #{data['name']}"
      user_cache[user_id] = data
    end<commit_msg>Get rid of some API data format notes in comments<commit_after>class Scamp
  module Users
    # Return the user_id if we haven't got the real name and
    # kick off a user data fetch
    def username_for(user_id)
      return user_cache[user_id]["name"] if user_cache[user_id]
      fetch_data_for(user_id)
      return user_id.to_s
    end
    
    private
    
    def fetch_data_for(user_id)
      url = "https://#{subdomain}.campfirenow.com/users/#{user_id}.json"
      http = EventMachine::HttpRequest.new(url).get(:head => {'authorization' => [api_key, 'X'], "Content-Type" => "application/json"})
      logger.debug http.inspect
      http.callback do
        logger.debug "Got the data for #{user_id}"
        update_user_cache_with(user_id, Yajl::Parser.parse(http.response)['user'])
      end
      http.errback do
        logger.error "Couldn't fetch user data for #{user_id} with url #{url}\n#{http.response_header.status.inspect}\n#{http.response_header.inspect}\n#{http.response.inspect}"
      end
    end
    
    def update_user_cache_with(user_id, data)
      logger.debug "Updated user cache for #{data['name']}"
      user_cache[user_id] = data
    end
{'fraction_non_alphanumeric': 0.13452914798206278, 'fraction_numerical': 0.006726457399103139, 'mean_word_length': 3.080792682926829, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, 'https://': 2, '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': '4581461', 'n_tokens_mistral': 910, 'n_tokens_neox': 902, 'n_words': 184}