<commit_before>module Api::V1
  class ApiController < ApplicationController
    before_action :authorize_account, :save_request_data, except: [:new_account, :cors_check, :auth]
    before_action :find_item, only: [:show, :destroy, :pull, :run, :raml_zip, :raml]
    before_action :authorize_action, except: [:auth, :new_account, :cors_check, :push]
    rescue_from Exception, :with => :exception_handler
    respond_to :json
    
    def cors_check
      self.cors_header
      render :text => '', :content_type => 'text/plain'
    end

    def index
      if klass = self.klass
        @items =
          if @criteria.present?
            if sort_key = @criteria.delete(:sort_by)
              asc = @criteria.has_key?(:ascending) | @criteria.has_key?(:asc)
              [:ascending, :asc, :descending, :desc].each { |key| @criteria.delete(key) }
            end
            if limit = @criteria.delete(:limit)
              limit = limit.to_s.to_i
              limit = nil if limit == 0
            end
            items = klass.where(@criteria)
            if sort_key
              items =
                if asc
                  items.ascending(sort_key)
                else
                  items.descending(sort_key)
                end
            end
            items = items.limit(limit) if limit
            items
          else
            klass.all
          end
          option = {}
          option[:only] = @only if @only
          option[:ignore] = @ignore if @ignore
          option[:include_id] = true
            items_data = @items.map do |item|
                            hash = item.default_hash(option)
                            hash.delete('_type')
                            @view.nil? ? hash : hash[@view]
                        end<commit_msg>Including _type attribute for subclass records<commit_after>module Api::V1
  class ApiController < ApplicationController
    before_action :authorize_account, :save_request_data, except: [:new_account, :cors_check, :auth]
    before_action :find_item, only: [:show, :destroy, :pull, :run, :raml_zip, :raml]
    before_action :authorize_action, except: [:auth, :new_account, :cors_check, :push]
    rescue_from Exception, :with => :exception_handler
    respond_to :json
    
    def cors_check
      self.cors_header
      render :text => '', :content_type => 'text/plain'
    end

    def index
      if klass = self.klass
        @items =
          if @criteria.present?
            if sort_key = @criteria.delete(:sort_by)
              asc = @criteria.has_key?(:ascending) | @criteria.has_key?(:asc)
              [:ascending, :asc, :descending, :desc].each { |key| @criteria.delete(key) }
            end
            if limit = @criteria.delete(:limit)
              limit = limit.to_s.to_i
              limit = nil if limit == 0
            end
            items = klass.where(@criteria)
            if sort_key
              items =
                if asc
                  items.ascending(sort_key)
                else
                  items.descending(sort_key)
                end
            end
            items = items.limit(limit) if limit
            items
          else
            klass.all
          end
          option = {}
          option[:only] = @only if @only
          option[:ignore] = @ignore if @ignore
          option[:include_id] = true
            items_data = @items.map do |item|
                            hash = item.default_hash(option)
                            hash.delete('_type') if item.class.eql?(klass)
                            @view.nil? ? hash : hash[@view]
                        end
{'fraction_non_alphanumeric': 0.10063413289219741, 'fraction_numerical': 0.0011028398125172319, 'mean_word_length': 1.5951359084406296, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '1354715', 'n_tokens_mistral': 1034, 'n_tokens_neox': 1029, 'n_words': 238}