<commit_before>module Spree
  module Api
    class ProductsController < Spree::Api::BaseController

      def index
        if params[:ids]
          @products = product_scope.where(:id => params[:ids].split(","))
        else
          @products = product_scope.ransack(params[:q]).result
        end

        @products = @products.distinct.page(params[:page]).per(params[:per_page])
      end

      def show
        @product = find_product(params[:id])
        respond_with(@product)
      end

      # Takes besides the products attributes either an array of variants or
      # an array of option types.
      #
      # By submitting an array of variants the option types will be created
      # using the *name* key in options hash. e.g
      #
      #   product: {
      #     ...
      #     variants: {<commit_msg>Send Surrogate-Control header in api/products requests<commit_after>module Spree
  module Api
    class ProductsController < Spree::Api::BaseController

      def index
        if params[:ids]
          @products = product_scope.where(:id => params[:ids].split(","))
        else
          @products = product_scope.ransack(params[:q]).result
        end

        @products = @products.page(params[:page]).per(params[:per_page])
        expires_in 3.minutes, :public => true
        headers['Surrogate-Control'] = "max-age=180"
      end

      def show
        @product = find_product(params[:id])
        respond_with(@product)
      end

      # Takes besides the products attributes either an array of variants or
      # an array of option types.
      #
      # By submitting an array of variants the option types will be created
      # using the *name* key in options hash. e.g
      #
      #   product: {
      #     ...
      #     variants: {
{'fraction_non_alphanumeric': 0.10354530106921778, 'fraction_numerical': 0.0022509848058525606, 'mean_word_length': 2.197841726618705, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '3221420', 'n_tokens_mistral': 499, 'n_tokens_neox': 480, 'n_words': 141}