Class: Admin::TagsController
Constant Summary
BaseController::INTERNAL_SERVER_ERROR_MESSAGE
Instance Method Summary
collapse
#destroy_session, #identity_cache_memoization, #sign_in_page, #user_developer_session
#append_info_to_payload
#dynamic_pricings_formatter, #link_to_admin_reservations_path_by_id, #link_to_admin_restaurants_path_by_id, #link_to_log, #optional_locales, #optional_locales_with_labels, #staff_signed_in?
#setup_locale
#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=
#check_boolean_param, #get_banners, #inventory_params, #reservation_params
Instance Method Details
#index ⇒ Object
10
11
12
13
14
15
|
# File 'app/controllers/admin/tags_controller.rb', line 10
def index
@categories = RestaurantTag.where('title_en LIKE ?', 'Categories:%').order(:id)
@categories_short_names =
%w(Romantic Lunch Brunch Bro Girls Mixologists Cafe Family Healthy Insta)
@restaurant_tag_groups = RestaurantTagGroup.exclude_deleted.order_by_rank.includes(:translations)
end
|
#index_category ⇒ Object
81
82
83
84
85
86
87
88
|
# File 'app/controllers/admin/tags_controller.rb', line 81
def index_category
@categories = []
@restaurant_categories = []
RestaurantTag.where('title_en LIKE ?', 'Categories:%').order(:id).each do |c|
@restaurant_categories[c.id] = c.restaurant_ids
@categories.push(id: c.id, name: "cat#{c.id}")
end
end
|
#index_restaurant_tag_groups ⇒ Object
135
136
137
138
139
140
141
142
|
# File 'app/controllers/admin/tags_controller.rb', line 135
def index_restaurant_tag_groups
@categories = []
@restaurant_categories = {}
RestaurantTagGroup.exclude_deleted.includes(:restaurants).order_by_rank.each do |c|
@restaurant_categories["c-#{c[:id]}"] = c.restaurants.pluck(:id)
@categories.push(id: c.id, name: "restaurant-tag-#{c.id}")
end
end
|
#index_tag ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'app/controllers/admin/tags_controller.rb', line 17
def index_tag
@new_restaurants = Restaurant.joins(:restaurant_tags).where('restaurant_tags.title_en LIKE ?',
'Admin:New').pluck(:id)
@recommended_restaurants = Restaurant.joins(:restaurant_tags).where('restaurant_tags.title_en LIKE ?',
'Admin:Recommended').pluck(:id)
@popular_restaurants = Restaurant.joins(:restaurant_tags).where('restaurant_tags.title_en LIKE ?',
'Admin:MostPopular')
end
|
#set_category ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# File 'app/controllers/admin/tags_controller.rb', line 90
def set_category
checked = params[:checked]
id = params[:id]
type = params[:type]
if checked.present? && id.present? && type.present?
restaurant = Restaurant.find params[:id]
tag = RestaurantTag.find(type)
if checked == 'true'
restaurant.restaurant_tags << tag
EventDrivenWorkers::HhSearch::ProducerWorker.perform_async(
EventDrivenClient::Constants::RESTAURANTS_TAGS_TOPIC,
EventDrivenClient::Constants::UPDATE_EVENT,
tag.id,
{
add: [id],
remove: [],
},
)
render json: { status: 'true', type: type, id: id }.to_json
else
restaurant.restaurant_tags.delete tag
EventDrivenWorkers::HhSearch::ProducerWorker.perform_async(
EventDrivenClient::Constants::RESTAURANTS_TAGS_TOPIC,
EventDrivenClient::Constants::UPDATE_EVENT,
tag.id,
{
add: [],
remove: [id],
},
)
render json: { status: 'false', type: type, id: id }.to_json
end
else
render json: { status: 'failed', message: 'Invalid parameter' }
end
end
|
#set_restaurant_tag_groups ⇒ Object
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
# File 'app/controllers/admin/tags_controller.rb', line 144
def set_restaurant_tag_groups
checked = params[:checked]
id = params[:id]
type = params[:type]
if checked.present? && id.present? && type.present?
restaurant = Restaurant.find id
tag = RestaurantTagGroup.exclude_deleted.find(type)
if checked == 'true'
tag.restaurants << restaurant
EventDrivenWorkers::HhSearch::ProducerWorker.perform_async(
EventDrivenClient::Constants::RESTAURANTS_TAG_GROUPS_TOPIC,
EventDrivenClient::Constants::UPDATE_EVENT,
tag.id,
{
add: [id],
remove: [],
},
)
render json: { status: 'true', type: type, id: id }.to_json
else
tag.restaurants.delete restaurant
EventDrivenWorkers::HhSearch::ProducerWorker.perform_async(
EventDrivenClient::Constants::RESTAURANTS_TAG_GROUPS_TOPIC,
EventDrivenClient::Constants::UPDATE_EVENT,
tag.id,
{
add: [],
remove: [id],
},
)
render json: { status: 'false', type: type, id: id }.to_json
end
else
render json: { status: 'failed', message: 'Invalid parameter' }
end
end
|
#set_tag ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'app/controllers/admin/tags_controller.rb', line 26
def set_tag
checked = params[:checked]
id = params[:id]
type = params[:type]
if checked.present? && id.present? && type.present?
restaurant = Restaurant.find params[:id]
tag_id = case type
when 'new'
170
when 'recommend'
171
when 'popular'
173
else
render(json: { status: :unprocessable_entity, message: 'Invalid parameter' }) && return
end
tag = RestaurantTag.find(tag_id)
if checked == 'true'
restaurant.restaurant_tags << tag
EventDrivenWorkers::HhSearch::ProducerWorker.perform_async(
EventDrivenClient::Constants::RESTAURANTS_TAGS_TOPIC,
EventDrivenClient::Constants::UPDATE_EVENT,
tag_id,
{
add: [id],
remove: [],
},
)
render json: { status: 'true', type: type, id: id }.to_json
else
restaurant.restaurant_tags.delete tag
EventDrivenWorkers::HhSearch::ProducerWorker.perform_async(
EventDrivenClient::Constants::RESTAURANTS_TAGS_TOPIC,
EventDrivenClient::Constants::UPDATE_EVENT,
tag_id,
{
add: [],
remove: [id],
},
)
render json: { status: 'false', type: type, id: id }.to_json
end
else
render json: { status: 'failed', message: 'Invalid parameter' }
end
end
|