<commit_before>class TheTradeAdmin::OrdersController < TheTradeAdmin::BaseController
  before_action :set_order, only: [:show, :edit, :update, :refund, :destroy]
  skip_before_action :verify_authenticity_token, only: [:refresh]

  def index
    query_params = params.permit(:id, :user_id, :payment_status, :payment_type)
    q_params = params.fetch(:q, {}).permit(:uuid)
    query_params.merge! q_params

    @orders = Order.default_where(query_params).page(params[:page])
  end

  def payments
    @orders = Order.default_where(params.permit(:id, :payment_status)).default_where(params.fetch(:q, {}).permit(:uuid)).page(params[:page])
  end

  def new
    @order = Order.new(user_id: params[:user_id])
    if params[:cart_item_id]
      @order.migrate_from_cart_item(params[:cart_item_id])
    else
      @order.migrate_from_cart_items
    end

    respond_to do |format|
      format.html
      format.json { render json: @order }
    end
  end

  def refresh
    @order = Order.new(user_id: params[:user_id])
    @order.assign_attributes order_params

    if params[:cart_item_id]<commit_msg>order by id desc<commit_after>class TheTradeAdmin::OrdersController < TheTradeAdmin::BaseController
  before_action :set_order, only: [:show, :edit, :update, :refund, :destroy]
  skip_before_action :verify_authenticity_token, only: [:refresh]

  def index
    query_params = params.permit(:id, :user_id, :payment_status, :payment_type)
    q_params = params.fetch(:q, {}).permit(:uuid)
    query_params.merge! q_params

    @orders = Order.default_where(query_params).order(id: :desc).page(params[:page])
  end

  def payments
    @orders = Order.default_where(params.permit(:id, :payment_status)).default_where(params.fetch(:q, {}).permit(:uuid)).page(params[:page])
  end

  def new
    @order = Order.new(user_id: params[:user_id])
    if params[:cart_item_id]
      @order.migrate_from_cart_item(params[:cart_item_id])
    else
      @order.migrate_from_cart_items
    end

    respond_to do |format|
      format.html
      format.json { render json: @order }
    end
  end

  def refresh
    @order = Order.new(user_id: params[:user_id])
    @order.assign_attributes order_params

    if params[:cart_item_id]
{'fraction_non_alphanumeric': 0.12714932126696832, 'fraction_numerical': 0.0, 'mean_word_length': 4.4727722772277225, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6535679', 'n_tokens_mistral': 758, 'n_tokens_neox': 745, 'n_words': 137}