<commit_before>class MapUrlBuilder

  def initialize(size)
    @size, @markers = size, []
  end

  def self.helper_map(users, repo)
    user_coords = users.map{|u| u.coords }
    MapUrlBuilder.new('500x300').add_markers('blue', user_coords).add_marker('red', repo.coords).url
  end

  def self.user_map(user)
    MapUrlBuilder.new('350x350').add_marker('blue', user.coords).url
  end

  def self.search_map(repos)
    MapUrlBuilder.new('250x250').add_markers('red', repos).url
  end

  def add_marker(colour, coords)
    @markers << build_string(colour, coords[:latitude], coords[:longitude])
    self
  end

  def add_markers(colour, items)
    items.each{ |i| @markers << build_string( colour, i.coords[:latitude], i.coords[:longitude] ) }
    self
  end

  def url
    "http://maps.google.com/maps/api/staticmap?&size=#{@size}&maptype=roadmap#{@markers.join}&sensor=false"
  end

  private

  def build_string(colour, latitude, longitude)
    return '' if [latitude, longitude].any?{|l| l.nil? }
    "&markers=color:#{colour}%7Clabel:O%7C#{latitude},#{longitude}"
  end

end<commit_msg>add smart zoom for map builder<commit_after>class MapUrlBuilder

  def initialize(size)
    @size, @markers = size, []
  end

  def self.user_map(user)
    map = MapUrlBuilder.new('350x350')
    map.add_marker('blue', user.coords)
    map.add_markers('red', user.helped_repos_coords)
    map.url
  end

  def self.search_map(repos)
    MapUrlBuilder.new('250x250').add_markers('red', repos.map(&:coords)).url
  end

  def add_marker(colour, coords)
    @markers << build_string(colour, coords[:latitude], coords[:longitude])
    self
  end

  def add_markers(colour, items)
    items.each{ |i| @markers << build_string( colour, i[:latitude], i[:longitude] ) }
    self
  end

  def url
    map_url = "http://maps.google.com/maps/api/staticmap?&size=#{@size}&maptype=roadmap#{@markers.join}&sensor=false"
    map_url << "&zoom=13" if map_url.scan(/markers/).count == 1
    map_url
  end

  private

  def build_string(colour, latitude, longitude)
    return '' if [latitude, longitude].any?{|l| l.nil? }
    "&markers=color:#{colour}%7Clabel:O%7C#{latitude},#{longitude}"
  end

end
{'fraction_non_alphanumeric': 0.1576036866359447, 'fraction_numerical': 0.017050691244239632, 'mean_word_length': 4.321078431372549, 'pattern_counts': {'":': 0, '<': 13, '<?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': '2462657', 'n_tokens_mistral': 855, 'n_tokens_neox': 797, 'n_words': 138}