Sha256: 4218fa842bb9a2ed11ff7e2ceac48ce5c11b8f007fce7c909f539261218e696a
Contents?: true
Size: 1.28 KB
Versions: 47
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true module Spree module Admin class SearchController < Spree::Admin::BaseController respond_to :json layout false # TODO: Clean this up by moving searching out to user_class_extensions # And then JSON building with something like Active Model Serializers def users if params[:ids] # split here may be String#split or Array#split, so we must flatten the results @users = Spree.user_class.where(id: params[:ids].split(',').flatten) else @users = Spree.user_class.ransack({ m: 'or', email_start: params[:q], addresses_firstname_start: params[:q], addresses_lastname_start: params[:q] }).result.limit(10) end end def products if params[:ids] # split here may be String#split or Array#split, so we must flatten the results @products = Spree::Product.where(id: params[:ids].split(",").flatten) else @products = Spree::Product.ransack(params[:q]).result end @products = @products.distinct.page(params[:page]).per(params[:per_page]) expires_in 15.minutes, public: true headers['Surrogate-Control'] = "max-age=#{15.minutes}" end end end end
Version data entries
47 entries across 47 versions & 2 rubygems