Class: Sentiero::Web::Views::EngagementView
- Inherits:
-
BaseView
- Object
- BaseView
- Sentiero::Web::Views::EngagementView
show all
- Defined in:
- lib/sentiero/web/views/engagement_view.rb
Constant Summary
Constants inherited
from BaseView
BaseView::TEMPLATES_DIR, BaseView::TEMPLATE_CACHE
Constants included
from Escaping
Escaping::HTML_UNSAFE_IN_SCRIPT, Escaping::HTML_UNSAFE_IN_SCRIPT_PATTERN
Instance Attribute Summary collapse
Attributes inherited from BaseView
#base_path, #csrf_token
Instance Method Summary
collapse
Methods inherited from BaseView
#built_asset, compiled_template, #escape_js, #h, #range_pairs, #render, #render_layout, #render_partial, #render_session_row
Methods included from Formatting
#format_duration, #format_vital, #parse_browser, #parse_device
Methods included from Escaping
#escape_html, #escape_js_string, #escape_json
Constructor Details
#initialize(sessions:, distribution:, scanned:, was_truncated:, sort:, since:, until_str:) ⇒ EngagementView
Returns a new instance of EngagementView.
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 10
def initialize(sessions:, distribution:, scanned:, was_truncated:, sort:, since:, until_str:)
super()
@sessions = sessions
@distribution = distribution
@scanned = scanned
@was_truncated = was_truncated
@sort = sort
@since = since
@until_str = until_str
end
|
Instance Attribute Details
#distribution ⇒ Object
Returns the value of attribute distribution.
21
22
23
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 21
def distribution
@distribution
end
|
#scanned ⇒ Object
Returns the value of attribute scanned.
21
22
23
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 21
def scanned
@scanned
end
|
#sessions ⇒ Object
Returns the value of attribute sessions.
21
22
23
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 21
def sessions
@sessions
end
|
#since ⇒ Object
Returns the value of attribute since.
21
22
23
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 21
def since
@since
end
|
#sort ⇒ Object
Returns the value of attribute sort.
21
22
23
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 21
def sort
@sort
end
|
#until_str ⇒ Object
Returns the value of attribute until_str.
21
22
23
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 21
def until_str
@until_str
end
|
#was_truncated ⇒ Object
Returns the value of attribute was_truncated.
21
22
23
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 21
def was_truncated
@was_truncated
end
|
Instance Method Details
#axis_y ⇒ Object
36
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 36
def axis_y = svg_height - 24
|
#badge_class(score) ⇒ Object
45
46
47
48
49
50
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 45
def badge_class(score)
if score >= 60 then "badge badge-danger"
elsif score >= 30 then "badge badge-warning"
else "text-gray-400"
end
end
|
#bar_gap ⇒ Object
35
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 35
def bar_gap = 12
|
#bar_h(count) ⇒ Object
41
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 41
def bar_h(count) = (count.to_f / max_count * (axis_y - chart_top)).round(1)
|
#bar_width ⇒ Object
39
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 39
def bar_width = (svg_width - bar_gap * (bin_count + 1)) / bin_count
|
#bar_x(i) ⇒ Object
42
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 42
def bar_x(i) = bar_gap + i * (bar_width + bar_gap)
|
#bar_y(count) ⇒ Object
43
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 43
def bar_y(count) = (axis_y - bar_h(count)).round(1)
|
#bin_count ⇒ Object
38
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 38
def bin_count = distribution.size
|
#chart_top ⇒ Object
37
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 37
def chart_top = 12
|
#chips(signals) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 52
def chips(signals)
chips = []
chips << "rage×#{signals[:rage_clicks]}" if signals[:rage_clicks].to_i > 0
chips << "dead×#{signals[:dead_clicks]}" if signals[:dead_clicks].to_i > 0
chips << "churn×#{signals[:nav_churn]}" if signals[:nav_churn].to_i > 0
chips << "idle #{(signals[:idle_ratio].to_f * 100).round}%" if signals[:idle_ratio].to_f > 0
chips << "thrash×#{signals[:thrashing_scroll]}" if signals[:thrashing_scroll].to_i > 0
chips << "bounce" if signals[:quick_bounce]
chips << "refill×#{signals[:form_refills]}" if signals[:form_refills].to_i > 0
chips << "err-abandon" if signals[:error_abandonment]
chips
end
|
#max_count ⇒ Object
40
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 40
def max_count = [distribution.values.max, 1].max
|
#sort_link(column) ⇒ Object
29
30
31
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 29
def sort_link(column)
"#{base_path}/analytics/engagement?" + Rack::Utils.build_query(range_pairs.merge("sort" => column))
end
|
#sorted_sessions ⇒ Object
25
26
27
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 25
def sorted_sessions
(sort == "duration") ? sessions.sort_by { |row| [-row[:duration_ms], row[:session_id]] } : sessions
end
|
#svg_height ⇒ Object
34
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 34
def svg_height = 140
|
#svg_width ⇒ Object
33
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 33
def svg_width = 360
|
#template ⇒ Object
23
|
# File 'lib/sentiero/web/views/engagement_view.rb', line 23
def template = "analytics_engagement.html.erb"
|