<commit_before>class TagController < ApplicationController
  layout 'default'
  before_filter :mod_only, :only => [:mass_edit, :edit_preview]
  before_filter :member_only, :only => [:update, :edit]

  def cloud
    @tags = Tag.find(:all, :conditions => "post_count > 0", :order => "post_count DESC", :limit => 100).sort {|a, b| a.name <=> b.name}
  end

  # Generates list of tag names matching parameter term.
  # Used by jquery.ui.autocomplete.
  def autocomplete_name
    @tags = Tag.where(['name ILIKE ?', "*#{params[:term]}*".to_escaped_for_sql_like]).pluck(:name)
    respond_to do |format|
      format.json { render :json => @tags }
    end
  end

  def summary
    if params[:version] then
      # HTTP caching is unreliable for XHR.  If a version is supplied, and the version
      # hasn't changed since then, return an empty response.
      version = Tag.get_summary_version
      if params[:version].to_i == version then
        render :json => {:version => version, :unchanged => true}
        return
      end
    end

    # This string is already JSON-encoded, so don't call to_json.
    render :json => Tag.get_json_summary
  end

  def index
    limit = case params[:limit].presence
            when nil then 50
            when "0" then nil
            else params[:limit].to_i
            end

    order = case params[:order]
            when "count"
              "post_count desc"
            when "date"
              "id desc"
            else
              "name"
            end

    @tags = Tag.all

    if params[:name].present?
      keyword = if params[:name].include? "*"
                  params[:name].to_escaped_for_sql_like
                else
                  "*#{params[:name]}*".to_escaped_for_sql_like
                end
      @tags = @tags.where "name LIKE ?", keyword
    end

    if params[:type].present?
      @tags = @tags.where tag_type => params[:type].to_i
    end
<commit_msg>Disallow limit=0 for html response.<commit_after>class TagController < ApplicationController
  layout 'default'
  before_filter :mod_only, :only => [:mass_edit, :edit_preview]
  before_filter :member_only, :only => [:update, :edit]

  def cloud
    @tags = Tag.find(:all, :conditions => "post_count > 0", :order => "post_count DESC", :limit => 100).sort {|a, b| a.name <=> b.name}
  end

  # Generates list of tag names matching parameter term.
  # Used by jquery.ui.autocomplete.
  def autocomplete_name
    @tags = Tag.where(['name ILIKE ?', "*#{params[:term]}*".to_escaped_for_sql_like]).pluck(:name)
    respond_to do |format|
      format.json { render :json => @tags }
    end
  end

  def summary
    if params[:version] then
      # HTTP caching is unreliable for XHR.  If a version is supplied, and the version
      # hasn't changed since then, return an empty response.
      version = Tag.get_summary_version
      if params[:version].to_i == version then
        render :json => {:version => version, :unchanged => true}
        return
      end
    end

    # This string is already JSON-encoded, so don't call to_json.
    render :json => Tag.get_json_summary
  end

  def index
    limit = case params[:limit].presence
            when nil
              50
            when "0"
              request.format.html? ? 30 : nil
            else
              params[:limit].to_i
            end

    order = case params[:order]
            when "count"
              "post_count desc"
            when "date"
              "id desc"
            else
              "name"
            end

    @tags = Tag.all

    if params[:name].present?
      keyword = if params[:name].include? "*"
                  params[:name].to_escaped_for_sql_like
                else
                  "*#{params[:name]}*".to_escaped_for_sql_like
                end
      @tags = @tags.where "name LIKE ?", keyword
    end

    if params[:type].present?
      @tags = @tags.where tag_type => params[:type].to_i
    end

{'fraction_non_alphanumeric': 0.11350939563230066, 'fraction_numerical': 0.004316912138141189, 'mean_word_length': 2.1411483253588517, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 29, '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': '1665150', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1156, 'n_words': 338}