discourse-subscriptions/app/controllers/admin_controller.rb

30 lines
550 B
Ruby
Raw Normal View History

2019-09-13 22:56:28 -04:00
# frozen_string_literal: true
module DiscoursePatrons
class AdminController < ::Admin::AdminController
def index
2019-09-15 07:00:39 -04:00
payments = Payment.all.order(payments_order)
2019-09-13 22:56:28 -04:00
render_serialized(payments, PaymentSerializer)
end
2019-09-15 07:00:39 -04:00
private
def payments_order
if %w(created_at amount).include?(params[:order])
{ params[:order] => ascending }
2019-09-15 07:00:39 -04:00
else
2019-09-15 08:03:42 -04:00
{ created_at: :desc }
end
end
def ascending
2019-09-15 08:03:42 -04:00
if params[:descending] == 'false'
:desc
else
:asc
2019-09-15 07:00:39 -04:00
end
end
2019-09-13 22:56:28 -04:00
end
end