Class: Workarea::Search::Admin::Order
Instance Method Summary
collapse
#created_at, for, #id, jump_to, #jump_to_param, #jump_to_route_helper, #jump_to_search_text, #releasable?, #sanitized_keywords, #status, #type
all, #as_bulk_document, current_index_prefix, #destroy, #initialize, #save
Instance Method Details
#as_document ⇒ Object
44
45
46
47
48
49
|
# File 'app/models/workarea/search/admin/order.rb', line 44
def as_document
super.merge(
total_price: model.total_price.to_f,
placed_at: model.placed_at
)
end
|
#facets ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'app/models/workarea/search/admin/order.rb', line 35
def facets
super.merge(
order_status: order_status,
payment_status: payment.status,
fulfillment_status: fulfillment.status,
traffic_referrer: traffic_referrer
)
end
|
#fulfillment ⇒ Object
68
69
70
|
# File 'app/models/workarea/search/admin/order.rb', line 68
def fulfillment
@fulfillment ||= Fulfillment.find_or_initialize_by(id: model.id)
end
|
#jump_to_position ⇒ Object
27
28
29
|
# File 'app/models/workarea/search/admin/order.rb', line 27
def jump_to_position
2
end
|
#jump_to_text ⇒ Object
19
20
21
22
23
24
25
|
# File 'app/models/workarea/search/admin/order.rb', line 19
def jump_to_text
if model.placed?
"#{model.id} - Placed @ #{model.placed_at.to_s(:short)}"
else
"#{model.id} - #{model.status.to_s.titleize}"
end
end
|
#keywords ⇒ Object
15
16
17
|
# File 'app/models/workarea/search/admin/order.rb', line 15
def keywords
super + [model.email] + fulfillment.packages.map(&:tracking_number)
end
|
#name ⇒ Object
5
6
7
8
9
|
# File 'app/models/workarea/search/admin/order.rb', line 5
def name
if payment.address.present?
"#{payment.address.last_name} #{payment.address.first_name}"
end
end
|
#order_status ⇒ Object
51
52
53
|
# File 'app/models/workarea/search/admin/order.rb', line 51
def order_status
model.status
end
|
#payment ⇒ Object
64
65
66
|
# File 'app/models/workarea/search/admin/order.rb', line 64
def payment
@payment ||= Payment.find_or_initialize_by(id: model.id)
end
|
#search_text ⇒ Object
11
12
13
|
# File 'app/models/workarea/search/admin/order.rb', line 11
def search_text
OrderText.new(model).text
end
|
#should_be_indexed? ⇒ Boolean
31
32
33
|
# File 'app/models/workarea/search/admin/order.rb', line 31
def should_be_indexed?
model.placed? || model.fraud_suspected?
end
|
#traffic_referrer ⇒ Object
55
56
57
58
|
# File 'app/models/workarea/search/admin/order.rb', line 55
def traffic_referrer
source = model.traffic_referrer&.medium || 'direct'
I18n.t('workarea.order.traffic_referrer')[source]
end
|
#updated_at ⇒ Object
60
61
62
|
# File 'app/models/workarea/search/admin/order.rb', line 60
def updated_at
[model, payment, fulfillment].map(&:updated_at).compact.max
end
|