Class: Blgr::PagesController
Instance Method Summary
collapse
#identity_cache_memoization, #set_select_data, #switch_locale
#append_info_to_payload
Instance Method Details
#dashboard ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'app/controllers/blgr/pages_controller.rb', line 14
def dashboard
@restaurants = Restaurant.includes(:translations).where(id: BlgrLib::RestaurantScope.new.ids).find_each.map do |r|
{
id: r.id,
name: r.name_en.to_s,
}
end
end
|
#root ⇒ Object
10
11
12
|
# File 'app/controllers/blgr/pages_controller.rb', line 10
def root
redirect_to new_blogger_session_path
end
|
#set_resource_type ⇒ Object
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
|
# File 'app/controllers/blgr/pages_controller.rb', line 27
def set_resource_type
@resource_type = params[:resource_type]
url_v2 = "utm_source=bloggerbooking&utm_medium=#{current_blogger.channel.uri_name}&utm_version=v2"
case @resource_type
when 'individual'
resource = Restaurant.find(params[:resource_id])
@link = "#{resource.decorate.canonical_link(locale: nil)}?#{url_v2}&utm_campaign=#{resource.friendly_id}"
@expiry_date = resource.expiry_date.strftime('%d %b %Y')
when 'group'
group_landing_page = GroupLandingPage.find(params[:resource_id])
@link = "#{AdminSetting.web_v2_host}/#{group_landing_page.friendly_id}?#{url_v2}&utm_campaign=#{group_landing_page.friendly_id}"
@expiry_date = group_landing_page.group&.restaurants&.order(expiry_date: :desc)&.limit(1).first&.expiry_date&.strftime('%d %b %Y')
@total_restaurants = group_landing_page.group&.restaurants&.size || 0
when 'branch'
resource = Branch.find(params[:resource_id])
group_landing_page = GroupLandingPage.find_by(group: resource)
@link = if group_landing_page.present?
"#{AdminSetting.web_v2_host}/#{group_landing_page.friendly_id}?#{url_v2}&utm_campaign=#{group_landing_page.friendly_id}"
else
"#{AdminSetting.web_v2_host}/restaurants/search?branch_id=#{resource.id}&#{url_v2}&utm_campaign=#{resource.name}"
end
@expiry_date = resource&.restaurants&.order(expiry_date: :desc)&.limit(1).first&.expiry_date&.strftime('%d %b %Y')
@total_restaurants = resource.restaurants.size
end
@short_link = begin
@link.present? ? MyUrlShortener.find_or_create(@link) : nil
rescue => e
APMErrorHandler.report(e, context: { link: @link, resource_type: @resource_type }, handled: false)
"Can't generate short link, please use the original link"
end
end
|
#utm_link ⇒ Object
23
24
25
|
# File 'app/controllers/blgr/pages_controller.rb', line 23
def utm_link
render 'blgr/pages/utm_link', layout: false
end
|