Class: Launchpad::API::V2::Public::IEO::SalesController
Instance Method Summary
collapse
included
Methods included from Response
#controller_namespace, #error_response, #errors_response, #json_response, #not_found
Instance Method Details
#index ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'app/controllers/launchpad/api/v2/public/ieo/sales_controller.rb', line 10
def index
ransack_params = {
state_in: params[:state],
currency_id_eq: params[:currency_id],
name_cont_all: params[:name]
}
sales = Launchpad::IEO::Sale.public_states.order(created_at: (params[:ordering] || :asc))
.ransack(ransack_params)
json_response(paginate(sales.result), 200)
end
|
#search ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/launchpad/api/v2/public/ieo/sales_controller.rb', line 31
def search
ransack_params = {
state_in: params[:state],
currency_id_eq: params[:currency_id],
name_cont_all: params[:name]
}
sales = Launchpad::IEO::Sale.includes(:pairs)
.public_states.order(Arel.sql("CASE state
WHEN 'ongoing' THEN '1'
WHEN 'preparing' THEN '2'
WHEN 'distributing' THEN '3'
WHEN 'refunding' THEN '4'
WHEN 'finished' THEN '5'
WHEN 'cancelled' THEN '6'
END")).order(created_at: :desc)
.ransack(ransack_params)
json_response(paginate(sales.result).map(&:sales_to_json), 200)
end
|
#show ⇒ Object
23
24
25
26
27
28
29
|
# File 'app/controllers/launchpad/api/v2/public/ieo/sales_controller.rb', line 23
def show
launchpad = Launchpad::IEO::Sale.find(params[:id])
additional_params = {
generic_bids: launchpad.orders.where("state = ? OR state = ?", 'active', 'completed').last(50).as_json(uid: true),
}
json_response(launchpad.as_json.merge(additional_params), 200)
end
|