<commit_before>module Carto

  class StaticMapsURLHelper

    def url_for_static_map(request, visualization, map_width, map_height)
      username = CartoDB.extract_subdomain(request)
      request_protocol = request.protocol.sub('://', '')
      static_maps_base_url(username, request_protocol) +
        static_maps_image_url_fragment(visualization.id, map_width, map_height)
    end

    def url_for_static_map_without_request(username, request_protocol, visualization, map_width, map_height)
      static_maps_base_url(username, request_protocol) +
        static_maps_image_url_fragment(visualization.id, map_width, map_height)
    end

    private

    # INFO: Assumes no trailing '/' comes inside, so returned string doesn't has it either
    def static_maps_base_url(username, request_protocol)
      config = get_cdn_config
      if !config.nil? && !config.empty?
        "#{request_protocol}://#{config[request_protocol]}/#{username}"
      else
        # sample format: {protocol}://{user}.{maps_domain}:{port}/
        # All parameters except {user} come already replaced
        ApplicationHelper.maps_api_template('public').sub('{user}', username)
      end
    end

    # INFO: To ease testing while we keep the config in a global array...
    def get_cdn_config
      Cartodb.config[:cdn_url]
    end

    def static_maps_image_url_fragment(visualization_id, width, height)
      template_id = CartoDB::NamedMapsWrapper::NamedMap.template_name(visualization_id)

      "/api/v1/map/static/named/#{template_id}/#{width}/#{height}.png"
    end

  end
end
<commit_msg>removes old nm from static_maps_url_helper.rb<commit_after>module Carto

  class StaticMapsURLHelper

    def url_for_static_map(request, visualization, map_width, map_height)
      username = CartoDB.extract_subdomain(request)
      request_protocol = request.protocol.sub('://', '')
      static_maps_base_url(username, request_protocol) +
        static_maps_image_url_fragment(visualization.id, map_width, map_height)
    end

    def url_for_static_map_without_request(username, request_protocol, visualization, map_width, map_height)
      static_maps_base_url(username, request_protocol) +
        static_maps_image_url_fragment(visualization.id, map_width, map_height)
    end

    private

    # INFO: Assumes no trailing '/' comes inside, so returned string doesn't has it either
    def static_maps_base_url(username, request_protocol)
      config = get_cdn_config
      if !config.nil? && !config.empty?
        "#{request_protocol}://#{config[request_protocol]}/#{username}"
      else
        # sample format: {protocol}://{user}.{maps_domain}:{port}/
        # All parameters except {user} come already replaced
        ApplicationHelper.maps_api_template('public').sub('{user}', username)
      end
    end

    # INFO: To ease testing while we keep the config in a global array...
    def get_cdn_config
      Cartodb.config[:cdn_url]
    end

    def static_maps_image_url_fragment(visualization_id, width, height)
      template_name = Carto::NamedMaps::Template.new(Carto::Visualization.find(visualization_id)).name

      "/api/v1/map/static/named/#{template_name}/#{width}/#{height}.png"
    end

  end
end

{'fraction_non_alphanumeric': 0.10059171597633136, 'fraction_numerical': 0.0006228589224540642, 'mean_word_length': 3.9415384615384617, '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': '4376553', 'n_tokens_mistral': 991, 'n_tokens_neox': 959, 'n_words': 196}