ahoy_captain 0.83 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -13
- data/Rakefile +23 -2
- data/app/assets/javascript/ahoy_captain/controllers/application_controller.js +20 -0
- data/app/assets/javascript/ahoy_captain/controllers/combobox_controller.js +371 -0
- data/app/assets/javascript/ahoy_captain/controllers/filter/item_controller.js +12 -0
- data/app/assets/javascript/ahoy_captain/controllers/filter_modal_controller.js +45 -0
- data/app/assets/javascript/ahoy_captain/controllers/frame_link_controller.js +20 -0
- data/app/assets/javascript/ahoy_captain/controllers/funnel_chart_controller.js +58 -16
- data/app/assets/javascript/ahoy_captain/controllers/interval_controller.js +5 -0
- data/app/assets/javascript/ahoy_captain/controllers/line_chart_controller.js +236 -22
- data/app/assets/javascript/ahoy_captain/controllers/map_controller.js +47 -0
- data/app/assets/javascript/ahoy_captain/controllers/predicate_select_controller.js +1 -1
- data/app/assets/javascript/ahoy_captain/controllers/properties_controller.js +8 -0
- data/app/assets/javascript/ahoy_captain/controllers/property_filter_controller.js +45 -0
- data/app/assets/javascript/ahoy_captain/controllers/realtime_controller.js +4 -2
- data/app/assets/javascript/ahoy_captain/controllers/tile_controller.js +33 -0
- data/app/assets/javascript/ahoy_captain/controllers/toggle_controller.js +17 -0
- data/app/assets/javascript/ahoy_captain/helpers/chart_utils.js +156 -0
- data/app/assets/javascript/ahoy_captain/helpers/countries.js +2261 -0
- data/app/assets/javascript/ahoy_captain/helpers/number_formatters.js +55 -0
- data/app/components/ahoy_captain/combobox_component.html.erb +33 -0
- data/app/components/ahoy_captain/combobox_component.rb +13 -0
- data/app/components/ahoy_captain/comparison_link_component.html.erb +17 -0
- data/app/components/ahoy_captain/comparison_link_component.rb +44 -0
- data/app/components/ahoy_captain/dropdown_button_component.html.erb +5 -5
- data/app/components/ahoy_captain/dropdown_link_component.html.erb +5 -7
- data/app/components/ahoy_captain/dropdown_link_component.rb +4 -0
- data/app/components/ahoy_captain/filter/dropdown_component.html.erb +50 -0
- data/app/components/ahoy_captain/filter/dropdown_component.rb +51 -0
- data/app/components/ahoy_captain/filter/modal_component.html.erb +7 -5
- data/app/components/ahoy_captain/filter/select_component.html.erb +23 -21
- data/app/components/ahoy_captain/filter/select_component.rb +24 -9
- data/app/components/ahoy_captain/filter/tag_component.html.erb +8 -4
- data/app/components/ahoy_captain/filter/tag_component.rb +6 -30
- data/app/components/ahoy_captain/filter/tag_container_component.html.erb +2 -3
- data/app/components/ahoy_captain/filter/tag_container_component.rb +1 -8
- data/app/components/ahoy_captain/previous_next_component.html.erb +8 -0
- data/app/components/ahoy_captain/previous_next_component.rb +11 -0
- data/app/components/ahoy_captain/stats/comparable_container_component.html.erb +25 -0
- data/app/components/ahoy_captain/stats/comparable_container_component.rb +86 -0
- data/app/components/ahoy_captain/stats/container_component.html.erb +15 -0
- data/app/components/ahoy_captain/stats/container_component.rb +26 -0
- data/app/components/ahoy_captain/sticky_nav_component.html.erb +28 -33
- data/app/components/ahoy_captain/sticky_nav_component.rb +19 -0
- data/app/components/ahoy_captain/table_component.html.erb +2 -2
- data/app/components/ahoy_captain/table_component.rb +15 -3
- data/app/components/ahoy_captain/tables/devices_table_component.rb +11 -0
- data/app/components/ahoy_captain/tables/dynamic_table.rb +13 -0
- data/app/components/ahoy_captain/tables/dynamic_table_component.rb +204 -0
- data/app/components/ahoy_captain/tables/goals_table_component.rb +17 -0
- data/app/components/ahoy_captain/tables/header_component.html.erb +5 -0
- data/app/components/ahoy_captain/tables/header_component.rb +18 -0
- data/app/components/ahoy_captain/tables/headers/header_component.html.erb +1 -1
- data/app/components/ahoy_captain/tables/headers/header_component.rb +4 -0
- data/app/components/ahoy_captain/tables/properties_table_component.rb +27 -0
- data/app/components/ahoy_captain/tables/row_component.html.erb +4 -0
- data/app/components/ahoy_captain/tables/rows/row_component.rb +2 -3
- data/app/components/ahoy_captain/tile_component.html.erb +21 -10
- data/app/components/ahoy_captain/tile_component.rb +10 -2
- data/app/components/ahoy_captain/tooltip_component.html.erb +2 -2
- data/app/controllers/ahoy_captain/application_controller.rb +7 -16
- data/app/controllers/ahoy_captain/exports_controller.rb +1 -2
- data/app/controllers/ahoy_captain/filters/base_controller.rb +1 -3
- data/app/controllers/ahoy_captain/filters/goals_controller.rb +9 -0
- data/app/controllers/ahoy_captain/filters/pages/actions_controller.rb +1 -1
- data/app/controllers/ahoy_captain/filters/pages/entry_pages_controller.rb +1 -1
- data/app/controllers/ahoy_captain/filters/pages/exit_pages_controller.rb +1 -1
- data/app/controllers/ahoy_captain/filters/properties/values_controller.rb +4 -4
- data/app/controllers/ahoy_captain/filters/sources_controller.rb +1 -1
- data/app/controllers/ahoy_captain/filters/utms_controller.rb +1 -1
- data/app/controllers/ahoy_captain/locations/cities_controller.rb +22 -0
- data/app/controllers/ahoy_captain/locations/countries_controller.rb +22 -0
- data/app/controllers/ahoy_captain/locations/maps_controller.rb +24 -0
- data/app/controllers/ahoy_captain/locations/regions_controller.rb +22 -0
- data/app/controllers/ahoy_captain/properties_controller.rb +41 -0
- data/app/controllers/ahoy_captain/stats/base_controller.rb +86 -5
- data/app/controllers/ahoy_captain/stats/bounce_rates_controller.rb +1 -1
- data/app/controllers/ahoy_captain/stats/total_pageviews_controller.rb +1 -1
- data/app/controllers/ahoy_captain/stats/total_visits_controller.rb +1 -1
- data/app/controllers/ahoy_captain/stats/unique_visitors_controller.rb +2 -1
- data/app/controllers/ahoy_captain/stats/views_per_visits_controller.rb +1 -10
- data/app/controllers/ahoy_captain/stats/visit_durations_controller.rb +1 -1
- data/app/helpers/ahoy_captain/application_helper.rb +60 -3
- data/app/models/ahoy_captain/comparison_mode.rb +72 -0
- data/app/models/ahoy_captain/filter_parser.rb +82 -0
- data/app/models/ahoy_captain/range_from_params.rb +78 -0
- data/app/models/ahoy_captain/rangeable.rb +0 -3
- data/app/models/concerns/ahoy_captain/compare_mode.rb +19 -0
- data/app/models/concerns/ahoy_captain/limitable.rb +17 -0
- data/app/models/concerns/ahoy_captain/range_options.rb +1 -14
- data/app/presenters/ahoy_captain/dashboard_presenter.rb +18 -54
- data/app/presenters/ahoy_captain/goals_presenter.rb +3 -2
- data/app/queries/ahoy_captain/application_query.rb +74 -10
- data/app/queries/ahoy_captain/event_query.rb +7 -2
- data/app/queries/ahoy_captain/stats/average_views_per_visit_query.rb +11 -4
- data/app/queries/ahoy_captain/stats/average_visit_duration_query.rb +14 -2
- data/app/queries/ahoy_captain/stats/base_query.rb +18 -0
- data/app/queries/ahoy_captain/stats/bounce_rates_query.rb +15 -1
- data/app/queries/ahoy_captain/stats/total_pageviews_query.rb +2 -2
- data/app/queries/ahoy_captain/stats/total_visitors_query.rb +1 -1
- data/app/queries/ahoy_captain/stats/unique_visitors_query.rb +1 -1
- data/app/queries/ahoy_captain/stats/views_per_visit_query.rb +1 -1
- data/app/queries/ahoy_captain/stats/visit_duration_query.rb +3 -3
- data/app/queries/ahoy_captain/visit_query.rb +1 -2
- data/app/queries/concerns/ahoy_captain/comparable_queries.rb +25 -0
- data/app/queries/concerns/ahoy_captain/comparable_query.rb +138 -0
- data/app/queries/concerns/ahoy_captain/lazy_comparable_query.rb +42 -0
- data/app/views/ahoy_captain/devices/_table.html.erb +1 -4
- data/app/views/ahoy_captain/funnels/show.html.erb +5 -2
- data/app/views/ahoy_captain/goals/index.html.erb +1 -4
- data/app/views/ahoy_captain/layouts/application.html.erb +3 -4
- data/app/views/ahoy_captain/layouts/shared/_tile_loader.html.erb +12 -0
- data/app/views/ahoy_captain/locations/maps/show.html.erb +3 -0
- data/app/views/ahoy_captain/properties/_form.html.erb +6 -0
- data/app/views/ahoy_captain/properties/index.html.erb +3 -0
- data/app/views/ahoy_captain/properties/show.html.erb +6 -0
- data/app/views/ahoy_captain/realtimes/show.html.erb +1 -1
- data/app/views/ahoy_captain/roots/_filters.html.erb +80 -0
- data/app/views/ahoy_captain/roots/show.html.erb +113 -122
- data/app/views/ahoy_captain/stats/base/index.html.erb +37 -8
- data/app/views/ahoy_captain/stats/show.html.erb +14 -56
- data/config/routes.rb +9 -3
- data/lib/ahoy_captain/ahoy/event_methods.rb +21 -14
- data/lib/ahoy_captain/ahoy/visit_methods.rb +1 -1
- data/lib/ahoy_captain/configuration.rb +18 -7
- data/lib/ahoy_captain/engine.rb +21 -0
- data/lib/ahoy_captain/filter_configuration/filter.rb +16 -0
- data/lib/ahoy_captain/filter_configuration/filter_collection.rb +48 -0
- data/lib/ahoy_captain/filters_configuration.rb +77 -0
- data/lib/ahoy_captain/goals.rb +1 -1
- data/lib/ahoy_captain/predicate_label.rb +7 -0
- data/lib/ahoy_captain/version.rb +1 -1
- data/lib/ahoy_captain.rb +8 -1
- data/lib/generators/ahoy_captain/templates/config.rb.tt +32 -0
- metadata +149 -22
- data/app/assets/javascript/ahoy_captain/controllers/active_links_controller.js +0 -15
- data/app/assets/javascript/ahoy_captain/controllers/filter_tag_controller.js +0 -20
- data/app/assets/javascript/ahoy_captain/controllers/search_select_controller.js +0 -65
- data/app/components/ahoy_captain/tables/headers/devices_header_component.html.erb +0 -3
- data/app/components/ahoy_captain/tables/headers/devices_header_component.rb +0 -9
- data/app/components/ahoy_captain/tables/headers/goals_header_component.html.erb +0 -6
- data/app/components/ahoy_captain/tables/headers/goals_header_component.rb +0 -9
- data/app/components/ahoy_captain/tables/rows/devices_row_component.html.erb +0 -5
- data/app/components/ahoy_captain/tables/rows/devices_row_component.rb +0 -12
- data/app/components/ahoy_captain/tables/rows/goals_row_component.html.erb +0 -11
- data/app/components/ahoy_captain/tables/rows/goals_row_component.rb +0 -12
- data/app/controllers/ahoy_captain/cities_controller.rb +0 -20
- data/app/controllers/ahoy_captain/countries_controller.rb +0 -20
- data/app/controllers/ahoy_captain/regions_controller.rb +0 -20
- /data/app/views/ahoy_captain/{cities → locations/cities}/index.html+details.erb +0 -0
- /data/app/views/ahoy_captain/{cities → locations/cities}/index.html.erb +0 -0
- /data/app/views/ahoy_captain/{countries → locations/countries}/index.html+details.erb +0 -0
- /data/app/views/ahoy_captain/{countries → locations/countries}/index.html.erb +0 -0
- /data/app/views/ahoy_captain/{regions → locations/regions}/index.html+details.erb +0 -0
- /data/app/views/ahoy_captain/{regions → locations/regions}/index.html.erb +0 -0
@@ -1,181 +1,172 @@
|
|
1
|
-
<main class='
|
1
|
+
<main class='w-screen overflow-hidden' data-action="combobox:init@window->application#comboboxInit">
|
2
|
+
<script id="tile-loader-template" type="template/html">
|
3
|
+
<%= render '/ahoy_captain/layouts/shared/tile_loader' %>
|
4
|
+
</script>
|
2
5
|
<%= render AhoyCaptain::StickyNavComponent.new do |nav| %>
|
3
6
|
<% nav.with_realtime_update do %>
|
4
|
-
<%= turbo_frame_tag :realtime, src: realtime_path, data: { controller: "realtime" }, loading: :lazy %>
|
7
|
+
<%= turbo_frame_tag :realtime, src: realtime_path, data: { controller: "realtime", "realtime-interval-value" => AhoyCaptain.config.realtime_interval.to_i }, loading: :lazy %>
|
5
8
|
<% end %>
|
6
9
|
<% end %>
|
7
10
|
|
8
|
-
<div class="grid grid-cols-1 lg:grid-cols-2 grid-flow-row gap-4">
|
9
|
-
<%= render AhoyCaptain::TileComponent.new(wide: true) do |component| %>
|
11
|
+
<div class="grid grid-cols-1 lg:grid-cols-2 grid-flow-row gap-4 min-h-screen pb-4 max-w-6xl mx-auto">
|
12
|
+
<%= render AhoyCaptain::TileComponent.new(wide: true, classes: "p-4 m-2") do |component| %>
|
10
13
|
<% component.with_statistic_display do %>
|
11
|
-
<%= turbo_frame_tag :stats, src: stats_path(search_params), loading: :lazy %>
|
14
|
+
<%= turbo_frame_tag :stats, src: stats_path(search_params), loading: :lazy, skeleton: false do %>
|
15
|
+
<div class="grid grid-cols-1 divide-y divide-base-200 overflow-hidden rounded-lg grid-cols-2 md:grid-cols-6 md:divide-y-0">
|
16
|
+
<% 6.times do %>
|
17
|
+
<div class="relative px-4 md:px-6 w-1/2 my-4 w-auto group cursor-pointer" >
|
18
|
+
<div role="status" class="max-w-sm animate-pulse">
|
19
|
+
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[120px] mb-2.5"></div>
|
20
|
+
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 mb-2.5 max-w-[60px]"></div>
|
21
|
+
<span class="sr-only">Loading...</span>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
</div>
|
26
|
+
<% end %>
|
27
|
+
<%= turbo_frame_tag :chart, src: stats_unique_visitors_path(search_params) do %>
|
28
|
+
<div role="status" class="p-4 animate-pulse md:p-6">
|
29
|
+
<div class="flex items-baseline mt-4 space-x-6">
|
30
|
+
<div class="w-full bg-gray-200 rounded-t-lg h-72 dark:bg-gray-700"></div>
|
31
|
+
<div class="w-full h-56 bg-gray-200 rounded-t-lg dark:bg-gray-700"></div>
|
32
|
+
<div class="w-full bg-gray-200 rounded-t-lg h-72 dark:bg-gray-700"></div>
|
33
|
+
<div class="w-full h-64 bg-gray-200 rounded-t-lg dark:bg-gray-700"></div>
|
34
|
+
<div class="w-full bg-gray-200 rounded-t-lg h-80 dark:bg-gray-700"></div>
|
35
|
+
<div class="w-full bg-gray-200 rounded-t-lg h-72 dark:bg-gray-700"></div>
|
36
|
+
<div class="w-full bg-gray-200 rounded-t-lg h-80 dark:bg-gray-700"></div>
|
37
|
+
</div>
|
38
|
+
<span class="sr-only">Loading...</span>
|
39
|
+
</div>
|
40
|
+
<% end %>
|
12
41
|
<% end %>
|
42
|
+
|
13
43
|
<% end %>
|
14
44
|
|
15
45
|
<%= render AhoyCaptain::TileComponent.new(title: 'Top Sources') do |component| %>
|
16
|
-
<% component.with_display_links do
|
17
|
-
<div
|
18
|
-
<
|
19
|
-
|
20
|
-
|
21
|
-
<%
|
22
|
-
|
23
|
-
<%= source.titleize.gsub("Utm", "UTM") %>
|
24
|
-
</a>
|
46
|
+
<% component.with_display_links do %>
|
47
|
+
<div class="flex text-xs font-medium text-gray-400 space-x-2">
|
48
|
+
<div class="relative inline-block text-left">
|
49
|
+
<%= component.link_to "All", sources_path(search_params), data: { turbo_frame: "sources" } %>
|
50
|
+
<%= render AhoyCaptain::DropdownLinkComponent.new(title: "Campaign") do |dropdown| %>
|
51
|
+
<% %w{utm_source utm_medium utm_term utm_content utm_campaign}.each do |source| %>
|
52
|
+
<%= dropdown.link_to source.titleize.gsub("Utm", "UTM"), public_send("campaign_#{source}_path".to_sym, **search_params), data: { turbo_frame: "sources" } %>
|
25
53
|
<% end %>
|
26
54
|
<% end %>
|
27
|
-
|
55
|
+
</div>
|
28
56
|
</div>
|
57
|
+
|
58
|
+
|
29
59
|
<% end %>
|
30
60
|
<% component.with_statistic_display do %>
|
31
|
-
<%= turbo_frame_tag :sources, src: sources_path(search_params), loading: :lazy %>
|
61
|
+
<%= turbo_frame_tag :sources, src: sources_path(search_params), loading: :lazy do %>
|
62
|
+
<%= render '/ahoy_captain/layouts/shared/tile_loader' %>
|
63
|
+
<% end %>
|
32
64
|
<% end %>
|
33
65
|
<% component.with_details_cta do %>
|
34
|
-
<button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#sources" class="link no-underline">Details</button>
|
66
|
+
<button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#sources" class="link no-underline ">Details</button>
|
35
67
|
<% end %>
|
36
68
|
<% end %>
|
37
69
|
|
38
70
|
<%= render AhoyCaptain::TileComponent.new(title: 'Top Pages') do |component| %>
|
39
71
|
<% component.with_display_links do %>
|
40
|
-
<div
|
41
|
-
<
|
42
|
-
|
43
|
-
|
72
|
+
<div class="flex text-xs font-medium text-gray-400 space-x-2">
|
73
|
+
<div class="relative inline-block text-left"><div>
|
74
|
+
<%= component.link_to "Top Pages", top_pages_path(search_params), data: { action: "click->tile#setTitle", turbo_frame: "pages" } %>
|
75
|
+
<%= component.link_to "Entry Pages", entry_pages_path(search_params), data: { action: "click->tile#setTitle", turbo_frame: "pages" } %>
|
76
|
+
<%= component.link_to "Exit Pages", exit_pages_path(search_params), data: { action: "click->tile#setTitle", turbo_frame: "pages" } %>
|
77
|
+
</div>
|
78
|
+
</div>
|
44
79
|
</div>
|
80
|
+
|
45
81
|
<% end %>
|
46
82
|
<% component.with_statistic_display do %>
|
47
|
-
<%= turbo_frame_tag :pages, src: top_pages_path(search_params), loading: :lazy %>
|
83
|
+
<%= turbo_frame_tag :pages, src: top_pages_path(search_params), loading: :lazy do %>
|
84
|
+
<%= render '/ahoy_captain/layouts/shared/tile_loader' %>
|
85
|
+
<% end %>
|
48
86
|
<% end %>
|
49
87
|
<% component.with_details_cta do %>
|
50
|
-
<button data-action="click->details-modal#openModal" data-controller="details-modal"
|
88
|
+
<button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#pages" class="link no-underline ">Details</button>
|
51
89
|
<% end %>
|
52
90
|
<% end %>
|
53
91
|
|
54
|
-
<%= render AhoyCaptain::TileComponent.new(title: '
|
92
|
+
<%= render AhoyCaptain::TileComponent.new(title: 'Map') do |component| %>
|
55
93
|
<% component.with_display_links do %>
|
56
|
-
<div
|
57
|
-
<
|
58
|
-
|
59
|
-
|
94
|
+
<div class="flex text-xs font-medium text-gray-400 space-x-2">
|
95
|
+
<div class="relative inline-block text-left">
|
96
|
+
<%= component.link_to "Map", locations_map_path(search_params), data: { action: "click->tile#setTitle", turbo_frame: "geography" } %>
|
97
|
+
<%= component.link_to "Countries", locations_countries_path(search_params), data: { action: "click->tile#setTitle", turbo_frame: "geography" } %>
|
98
|
+
<%= component.link_to "Regions", locations_regions_path(search_params), data: { action: "click->tile#setTitle", turbo_frame: "geography" } %>
|
99
|
+
<%= component.link_to "Cities", locations_cities_path(search_params), data: { action: "click->tile#setTitle", turbo_frame: "geography" } %>
|
100
|
+
</div>
|
60
101
|
</div>
|
61
102
|
<% end %>
|
62
103
|
<% component.with_statistic_display do %>
|
63
|
-
<%= turbo_frame_tag :geography, src:
|
104
|
+
<%= turbo_frame_tag :geography, src: locations_map_path(search_params), loading: :lazy do %>
|
105
|
+
<%= render '/ahoy_captain/layouts/shared/tile_loader' %>
|
106
|
+
|
107
|
+
<% end %>
|
64
108
|
<% end %>
|
65
109
|
<% component.with_details_cta do %>
|
66
|
-
<button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#geography" class="link no-underline">Details</button>
|
110
|
+
<button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#geography" class="link no-underline ">Details</button>
|
67
111
|
<% end %>
|
68
112
|
<% end %>
|
69
113
|
|
70
114
|
<%= render AhoyCaptain::TileComponent.new(title: 'Devices') do |component| %>
|
71
115
|
<% component.with_display_links do %>
|
72
|
-
<div
|
73
|
-
<
|
74
|
-
|
75
|
-
|
116
|
+
<div class="flex text-xs font-medium text-gray-400 space-x-2">
|
117
|
+
<div class="relative inline-block text-left">
|
118
|
+
<%= component.link_to "Browser", devices_browsers_path(search_params), data: { turbo_frame: "devices" } %>
|
119
|
+
<%= component.link_to "OS", devices_operating_systems_path(search_params), data: { turbo_frame: "devices" } %>
|
120
|
+
<%= component.link_to "Size", devices_device_types_path(search_params), data: { turbo_frame: "devices" } %>
|
121
|
+
</div>
|
76
122
|
</div>
|
77
123
|
<% end %>
|
78
124
|
<% component.with_statistic_display do %>
|
79
|
-
<%= turbo_frame_tag :devices, src: devices_browsers_path(search_params), loading: :lazy %>
|
125
|
+
<%= turbo_frame_tag :devices, src: devices_browsers_path(search_params), loading: :lazy do %>
|
126
|
+
<%= render '/ahoy_captain/layouts/shared/tile_loader' %>
|
127
|
+
|
128
|
+
<% end %>
|
80
129
|
<% end %>
|
81
130
|
<% component.with_details_cta do %>
|
82
|
-
<button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#devices" class="link no-underline">Details</button>
|
131
|
+
<button data-action="click->details-modal#openModal" data-controller="details-modal" data-details-modal-target-value="#devices" class="link no-underline ">Details</button>
|
83
132
|
<% end %>
|
84
133
|
<% end %>
|
85
|
-
<%= render AhoyCaptain::TileComponent.new(wide: true) do |component| %>
|
134
|
+
<%= render AhoyCaptain::TileComponent.new(title: "Goals and Funnels", wide: true, classes: "p-4 m-2") do |component| %>
|
86
135
|
<% component.with_display_links do %>
|
87
|
-
<
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
136
|
+
<div>
|
137
|
+
<div >
|
138
|
+
<div class="flex text-xs font-medium text-gray-400 space-x-2">
|
139
|
+
<div class="relative inline-block text-left">
|
140
|
+
<a href="<%= goals_path(search_params) %>" data-turbo-frame="goals" class="inline-block h-5 font-semibold" data-controller="frame-link" data-action="click->tile#setTitle">Goals</a>
|
141
|
+
<a href="<%= properties_path(search_params) %>" data-turbo-frame="goals" class="inline-block h-5 font-semibold" data-controller="frame-link" data-action="click->tile#setTitle">Properties</a>
|
142
|
+
<%= render AhoyCaptain::DropdownLinkComponent.new(title: "Funnels") do |dropdown| %>
|
143
|
+
<% AhoyCaptain.config.funnels.each do |id, funnel| %>
|
144
|
+
<% dropdown.with_option do %>
|
145
|
+
<a href="<%= funnel_path(id, search_params) %>" data-turbo-frame="goals" class="link " data-action="click->tile#setTitle" title="<%= funnel.title %> Funnel">
|
146
|
+
<%= funnel.title %>
|
147
|
+
</a>
|
148
|
+
<% end %>
|
149
|
+
<% end %>
|
150
|
+
<% end %>
|
151
|
+
</div>
|
152
|
+
</div>
|
153
|
+
|
154
|
+
</div>
|
155
|
+
</div>
|
100
156
|
<% end %>
|
101
157
|
<% component.with_statistic_display do %>
|
102
|
-
|
158
|
+
<div class="p-4">
|
159
|
+
<%= turbo_frame_tag :goals, src: goals_path(search_params), loading: :lazy do %>
|
160
|
+
<%= render '/ahoy_captain/layouts/shared/tile_loader' %>
|
161
|
+
<% end %>
|
162
|
+
|
163
|
+
</div>
|
103
164
|
<% end %>
|
104
165
|
<% end %>
|
105
166
|
</div>
|
106
167
|
</main>
|
107
168
|
|
108
|
-
<%=
|
109
|
-
<%= form.hidden_field :period, value: params[:period] %>
|
110
|
-
<%= form.hidden_field :start_date, value: params[:start_date] %>
|
111
|
-
<%= form.hidden_field :end_date, value: params[:end_date] %>
|
112
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Page", id: "pageModal") do |modal| %>
|
113
|
-
<% modal.with_modal_display do %>
|
114
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Action", column: :route, url: filters_actions_path, predicates: [:in, :not_in], form: form) %>
|
115
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Entry page", column: :entry_page, url: filters_entry_pages_path, predicates: [:in, :not_in], form: form) %>
|
116
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Exit page", column: :exit_page, url: filters_exit_pages_path, predicates: [:in, :not_in], form: form) %>
|
117
|
-
<% end %>
|
118
|
-
<% end %>
|
119
|
-
|
120
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Country", id: "countryModal") do |modal| %>
|
121
|
-
<% modal.with_modal_display do %>
|
122
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Country", column: :country, url: filters_locations_countries_path, predicates: [:in, :not_in], form: form) %>
|
123
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Region", column: :region, url: filters_locations_regions_path, predicates: [:in, :not_in], form: form) %>
|
124
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "City", column: :city, url: filters_locations_cities_path, predicates: [:in, :not_in], form: form) %>
|
125
|
-
<% end %>
|
126
|
-
<% end %>
|
127
|
-
|
128
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Source", id: "sourceModal") do |modal| %>
|
129
|
-
<% modal.with_modal_display do %>
|
130
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Source", column: :referring_domain, url: filters_sources_path, predicates: [:in, :not_in], form: form) %>
|
131
|
-
<% end %>
|
132
|
-
<% end %>
|
133
|
-
|
134
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Screen size", id: "screenModal") do |modal| %>
|
135
|
-
<% modal.with_modal_display do %>
|
136
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Screen size", column: :device_type, url: filters_screens_path, predicates: [:in, :not_in], form: form) %>
|
137
|
-
<% end %>
|
138
|
-
<% end %>
|
139
|
-
|
140
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Browser", id: "osModal") do |modal| %>
|
141
|
-
<% modal.with_modal_display do %>
|
142
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Operating System", column: :os, url: filters_names_path, predicates: [:in, :not_in], form: form) %>
|
143
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "Operating System Version", column: :os_version, url: filters_versions_path, predicates: [:in, :not_in], form: form) %>
|
144
|
-
<% end %>
|
145
|
-
<% end %>
|
146
|
-
|
147
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Filter by Campaign", id: "utmModal") do |modal| %>
|
148
|
-
<% modal.with_modal_display do %>
|
149
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "UTM Medium", column: :utm_medium, url: filters_utm_mediums_path, predicates: [:in, :not_in], form: form) %>
|
150
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "UTM Source", column: :utm_source, url: filters_utm_sources_path, predicates: [:in, :not_in], form: form) %>
|
151
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "UTM Campaign", column: :utm_campaign, url: filters_utm_campaigns_path, predicates: [:in, :not_in], form: form) %>
|
152
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "UTM Term", column: :utm_term, url: filters_utm_terms_path, predicates: [:in, :not_in], form: form) %>
|
153
|
-
<%= render AhoyCaptain::Filter::SelectComponent.new(label: "UTM Content", column: :utm_content, url: filters_utm_contents_path, predicates: [:in, :not_in], form: form) %>
|
154
|
-
<% end %>
|
155
|
-
<% end %>
|
156
|
-
|
157
|
-
|
158
|
-
<%= render AhoyCaptain::Filter::ModalComponent.new(title: "Custom Range", id: "customRangeModal") do |modal| %>
|
159
|
-
<% modal.with_modal_display do %>
|
160
|
-
<div class="flex gap-2 w-full">
|
161
|
-
<div class="form-control w-full max-w-xs">
|
162
|
-
<label class="label" for="start_date">
|
163
|
-
<span class="label-text">Start Date</span>
|
164
|
-
</label>
|
165
|
-
<input type="datetime-local" id="start_date" name="start_date" class="input input-bordered w-full" value="<%= params[:start_date] %>" />
|
166
|
-
</div>
|
167
|
-
<div class="form-control w-full max-w-xs">
|
168
|
-
<label class="label" for="end_date">
|
169
|
-
<span class="label-text">End Date</span>
|
170
|
-
</label>
|
171
|
-
<input type="datetime-local" id="end_date" name="end_date" class="input input-bordered w-full" value="<%= params[:end_date] %>" />
|
172
|
-
</div>
|
173
|
-
</div>
|
174
|
-
<% end %>
|
175
|
-
<% end %>
|
176
|
-
|
177
|
-
|
178
|
-
<% end %>
|
169
|
+
<%= render 'ahoy_captain/roots/filters' %>
|
179
170
|
|
180
171
|
<dialog id="detailsModal" class="modal">
|
181
172
|
<div class="modal-box w-11/12 max-w-5xl">
|
@@ -1,11 +1,40 @@
|
|
1
1
|
<%= turbo_frame_tag :chart do %>
|
2
|
-
<div class="
|
3
|
-
<
|
4
|
-
|
5
|
-
<%=
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
<div class="p-4">
|
3
|
+
<div class="flex justify-end gap-3 items-center ">
|
4
|
+
<a href="<%= export_path(request.query_parameters) %>" class="link text-sm" target="_blank" data-turbo-frame="false">Download</a>
|
5
|
+
<%= form_with url: url_for(params.permit!), method: :get, data: { controller: "interval" } do %>
|
6
|
+
<%= select_tag :interval, options_for_select(available_intervals.collect { |interval| [interval.titleize, interval] }, selected: selected_interval), class: "select text-accent select-sm w-full max-w-sm", 'data-action': "change->interval#handleChange" %>
|
7
|
+
<% end %>
|
8
|
+
</div>
|
9
|
+
<div>
|
10
|
+
<canvas id="overlay" width="600" height="400" style="position:absolute;pointer-events:none;"></canvas>
|
11
|
+
|
12
|
+
<% if compare_mode? %>
|
13
|
+
<canvas class="h-[300px] w-full"
|
14
|
+
data-controller="line-chart"
|
15
|
+
data-line-chart-label-value="<%= @label %>"
|
16
|
+
data-line-chart-interval-value="<%= selected_interval %>"
|
17
|
+
data-line-chart-current-value="<%= @stats.current.to_json %>"
|
18
|
+
data-line-chart-comparison-value="<%= params[:comparison] %>"
|
19
|
+
data-line-chart-compared-to-value="<%= @stats.compared_to.to_json %>"
|
20
|
+
data-line-chart-metric-value="<%= metric_type(@stats) %>"
|
21
|
+
data-action="resize@window->line-chart#resize"
|
22
|
+
data-action="mouseenter->line-chart#hover"
|
23
|
+
data-action="mouseleave->line-chart#hover"
|
24
|
+
></canvas>
|
25
|
+
<% else %>
|
26
|
+
<canvas class="h-[300px] w-full"
|
27
|
+
data-controller="line-chart"
|
28
|
+
data-line-chart-label-value="<%= @label %>"
|
29
|
+
data-line-chart-interval-value="<%= selected_interval %>"
|
30
|
+
data-line-chart-current-value="<%= @stats.to_json %>"
|
31
|
+
data-line-chart-metric-value="<%= metric_type(@stats) %>"
|
32
|
+
data-action="resize@window->line-chart#resize"
|
33
|
+
data-action="mouseenter->line-chart#hover"
|
34
|
+
data-action="mouseleave->line-chart#hover"
|
35
|
+
></canvas>
|
36
|
+
<% end %>
|
37
|
+
</div>
|
10
38
|
</div>
|
39
|
+
|
11
40
|
<% end %>
|
@@ -1,57 +1,15 @@
|
|
1
|
-
<%= turbo_frame_tag :stats do %>
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
<%= number_with_delimiter @presenter.total_visits %>
|
16
|
-
</div>
|
17
|
-
</dd>
|
18
|
-
</a>
|
19
|
-
<a href="<%= stats_total_pageviews_path(search_params) %>" data-turbo-frame="chart">
|
20
|
-
<dt class="text-base font-normal text-base-content">Total Pageviews</dt>
|
21
|
-
<dd class="mt-1 flex items-baseline justify-between md:block lg:flex">
|
22
|
-
<div class="flex items-baseline text-2xl font-semibold text-accent-content">
|
23
|
-
<%= number_with_delimiter @presenter.total_pageviews %>
|
24
|
-
</div>
|
25
|
-
</dd>
|
26
|
-
</a>
|
27
|
-
<a href="<%= stats_views_per_visits_path(search_params) %>" data-turbo-frame="chart">
|
28
|
-
|
29
|
-
<dt class="text-base font-normal text-base-content">Views per visit</dt>
|
30
|
-
<dd class="mt-1 flex items-baseline justify-between md:block lg:flex">
|
31
|
-
<div class="flex items-baseline text-2xl font-semibold text-accent-content">
|
32
|
-
<%= number_with_delimiter @presenter.views_per_visit %>
|
33
|
-
</div>
|
34
|
-
</dd>
|
35
|
-
</a>
|
36
|
-
<a href="<%= stats_bounce_rates_path(search_params) %>" data-turbo-frame="chart">
|
37
|
-
|
38
|
-
<dt class="text-base font-normal text-base-content">Bounce rate</dt>
|
39
|
-
<dd class="mt-1 flex items-baseline justify-between md:block lg:flex">
|
40
|
-
<div class="flex items-baseline text-2xl font-semibold text-accent-content">
|
41
|
-
<%= number_with_delimiter @presenter.bounce_rate %>%
|
42
|
-
</div>
|
43
|
-
</dd>
|
44
|
-
</a>
|
45
|
-
<a href="<%= stats_visit_durations_path(search_params) %>" data-turbo-frame="chart">
|
46
|
-
|
47
|
-
<dt class="text-base font-normal text-base-content">Visit duration</dt>
|
48
|
-
<dd class="mt-1 flex items-baseline justify-between md:block lg:flex">
|
49
|
-
<div class="flex items-baseline text-2xl font-semibold text-accent-content">
|
50
|
-
<%= @presenter.visit_duration %>
|
51
|
-
</div>
|
52
|
-
</dd>
|
53
|
-
</a>
|
54
|
-
</dl>
|
55
|
-
<%= turbo_frame_tag :chart, src: stats_unique_visitors_path(search_params) do %>
|
56
|
-
<% end %>
|
1
|
+
<%= turbo_frame_tag :stats, data: { controller: "active-frame-link" } do %>
|
2
|
+
<div class="grid grid-cols-1 divide-y divide-base-200 overflow-hidden rounded-lg grid-cols-2 md:grid-cols-6 md:divide-y-0" data-controller="active-links" data-active-links-classes-value='["text-primary"]'>
|
3
|
+
<% if @presenter.send(:range).realtime? %>
|
4
|
+
<%= render stats_container(@presenter.unique_visitors, stats_unique_visitors_url(search_params), "Unique Visits (30 min)", :number_with_delimiter, true) %>
|
5
|
+
<%= render stats_container(@presenter.total_pageviews, stats_total_pageviews_path(search_params), "Total Pageviews (30 min)", :number_with_delimiter) %>
|
6
|
+
<% else %>
|
7
|
+
<%= render stats_container(@presenter.unique_visitors, stats_unique_visitors_url(search_params), "Unique Visits", :number_with_delimiter, true) %>
|
8
|
+
<%= render stats_container(@presenter.total_visits, stats_total_visits_path(search_params), "Total Visits", :number_with_delimiter) %>
|
9
|
+
<%= render stats_container(@presenter.total_pageviews, stats_total_pageviews_path(search_params), "Total Pageviews", :number_with_delimiter) %>
|
10
|
+
<%= render stats_container(@presenter.views_per_visit, stats_views_per_visits_path(search_params), "Views per Visit", :number_with_delimiter) %>
|
11
|
+
<%= render stats_container(@presenter.bounce_rate, stats_bounce_rates_path(search_params), "Bounce Rate", :number_with_delimiter) %>
|
12
|
+
<%= render stats_container(@presenter.visit_duration, stats_visit_durations_url(search_params), "Visit Duration", :number_to_duration) %>
|
13
|
+
<% end %>
|
14
|
+
</div>
|
57
15
|
<% end %>
|
data/config/routes.rb
CHANGED
@@ -12,14 +12,19 @@ AhoyCaptain::Engine.routes.draw do
|
|
12
12
|
get "/devices/#{k}" => 'devices#index', defaults: { devices_type: v }, as: "devices_#{k}"
|
13
13
|
end
|
14
14
|
|
15
|
+
namespace :locations do
|
16
|
+
resource :map, only: [:show]
|
17
|
+
resources :countries, only: [:index]
|
18
|
+
resources :regions, only: [:index]
|
19
|
+
resources :cities, only: [:index]
|
20
|
+
end
|
21
|
+
|
22
|
+
resources :properties, only: [:index, :show]
|
15
23
|
resource :export, only: [:show]
|
16
24
|
resource :realtime, only: [:show]
|
17
25
|
resources :funnels, only: [:show]
|
18
26
|
resources :goals, only: [:index]
|
19
27
|
resource :stats, only: [:show]
|
20
|
-
resources :countries, only: [:index]
|
21
|
-
resources :regions, only: [:index]
|
22
|
-
resources :cities, only: [:index]
|
23
28
|
resources :campaigns, only: [:index]
|
24
29
|
resources :sources, only: [:index]
|
25
30
|
resources :exit_pages, only: [:index]
|
@@ -48,6 +53,7 @@ AhoyCaptain::Engine.routes.draw do
|
|
48
53
|
resources :values, only: [:index]
|
49
54
|
end
|
50
55
|
|
56
|
+
resources :goals, only: [:index]
|
51
57
|
resources :sources, only: [:index]
|
52
58
|
resources :screens, only: [:index]
|
53
59
|
scope :operating_systems, module: :operating_systems do
|
@@ -4,6 +4,8 @@ module AhoyCaptain
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
+
scope :page_view, -> { where("name = '#{AhoyCaptain.config.event[:view_name]}'") }
|
8
|
+
|
7
9
|
ransacker :route do |_parent|
|
8
10
|
Arel.sql(AhoyCaptain.config.event[:url_column])
|
9
11
|
end
|
@@ -17,10 +19,13 @@ module AhoyCaptain
|
|
17
19
|
end
|
18
20
|
|
19
21
|
scope :with_entry_pages, -> {
|
20
|
-
with(entry_pages: self.select("MIN(
|
22
|
+
with(entry_pages: self.select("MIN(#{table_name}.id) as min_id, #{Arel.sql("#{AhoyCaptain.config.event.url_column} AS url")}").where(name: AhoyCaptain.config.event[:view_name]).group("#{table_name}.properties")).joins("INNER JOIN entry_pages ON entry_pages.min_id = #{table_name}.id")
|
21
23
|
}
|
24
|
+
|
22
25
|
scope :with_exit_pages, -> {
|
23
|
-
with(exit_pages: self.select("MAX(
|
26
|
+
with(exit_pages: self.select("MAX(#{table_name}.id) as max_id, #{Arel.sql("#{AhoyCaptain.config.event.url_column} AS url")}")
|
27
|
+
.where(name: AhoyCaptain.config.event[:view_name]).group("#{table_name}.properties"))
|
28
|
+
.joins("INNER JOIN exit_pages ON exit_pages.max_id = #{table_name}.id")
|
24
29
|
}
|
25
30
|
|
26
31
|
scope :with_routes, -> { where(AhoyCaptain.config.event[:url_exists]) }
|
@@ -33,29 +38,31 @@ module AhoyCaptain
|
|
33
38
|
distinct(Arel.sql("#{AhoyCaptain.config.event.url_column}"))
|
34
39
|
}
|
35
40
|
|
36
|
-
scope :
|
37
|
-
where("properties
|
41
|
+
scope :with_property_values, ->(value) {
|
42
|
+
where("JSONB_EXISTS(properties, '#{value}')")
|
38
43
|
}
|
39
44
|
|
40
|
-
|
41
|
-
|
42
|
-
|
45
|
+
ransacker :properties, args: [:parent, :ransacker_args] do |parent, args|
|
46
|
+
Arel::Nodes::InfixOperation.new('->>', parent.table[:properties], Arel::Nodes.build_quoted(args))
|
47
|
+
end
|
43
48
|
|
44
|
-
|
45
|
-
|
49
|
+
ransacker :goal,
|
50
|
+
formatter: ->(value) {
|
51
|
+
::Arel::Nodes::SqlLiteral.new(
|
52
|
+
::AhoyCaptain.config.goals[value].event_query.call.select(:id).to_sql
|
53
|
+
)
|
54
|
+
} do |parent|
|
55
|
+
parent.table[:id]
|
46
56
|
end
|
47
57
|
end
|
48
58
|
|
49
59
|
class_methods do
|
50
60
|
def ransackable_attributes(auth_object = nil)
|
51
|
-
super + ["action", "controller", "id",
|
61
|
+
super + [ "action", "controller", "id", "name", "page", "properties", "time", "url", "user_id", "visit_id", "goal"] + self._ransackers.keys
|
52
62
|
end
|
53
63
|
|
54
64
|
def ransackable_scopes(auth_object = nil)
|
55
|
-
super + [
|
56
|
-
:properties_eq,
|
57
|
-
:properties_not_eq
|
58
|
-
]
|
65
|
+
super + [:with_property_values, :property_value_i_cont]
|
59
66
|
end
|
60
67
|
|
61
68
|
def ransackable_associations(auth_object = nil)
|
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'ahoy_captain/period_collection'
|
2
|
+
require 'ahoy_captain/filters_configuration'
|
2
3
|
|
3
4
|
module AhoyCaptain
|
4
5
|
class Configuration
|
5
|
-
attr_accessor :view_name, :theme
|
6
|
-
attr_reader :goals, :funnels, :cache, :ranges, :disabled_widgets, :event, :models
|
6
|
+
attr_accessor :view_name, :theme, :realtime_interval
|
7
|
+
attr_reader :goals, :funnels, :cache, :ranges, :disabled_widgets, :event, :models, :filters, :predicate_labels
|
7
8
|
def initialize
|
8
9
|
@goals = GoalCollection.new
|
9
10
|
@funnels = FunnelCollection.new
|
@@ -14,15 +15,25 @@ module AhoyCaptain
|
|
14
15
|
option.store = Rails.cache
|
15
16
|
option.ttl = 1.minute
|
16
17
|
end
|
17
|
-
@event = ActiveSupport::OrderedOptions.new.tap do |option|
|
18
|
-
option.view_name = "$view"
|
19
|
-
option.url_column = "CONCAT(ahoy_events.properties->>'controller', '#', ahoy_events.properties->>'action')"
|
20
|
-
option.url_exists = "JSONB_EXISTS(ahoy_events.properties, 'controller') AND JSONB_EXISTS(ahoy_events.properties, 'action')"
|
21
|
-
end
|
22
18
|
@models = ActiveSupport::OrderedOptions.new.tap do |option|
|
23
19
|
option.event = "::Ahoy::Event"
|
24
20
|
option.visit = "::Ahoy::Visit"
|
25
21
|
end
|
22
|
+
@event = ActiveSupport::OrderedOptions.new.tap do |option|
|
23
|
+
option.view_name = "$view"
|
24
|
+
option.url_column = "CONCAT(#{@models.event.parameterize.tableize}.properties->>'controller', '#', #{@models.event.parameterize.tableize}.properties->>'action')"
|
25
|
+
option.url_exists = "JSONB_EXISTS(#{@models.event.parameterize.tableize}.properties, 'controller') AND JSONB_EXISTS(#{@models.event.parameterize.tableize}.properties, 'action')"
|
26
|
+
end
|
27
|
+
@filters = FiltersConfiguration.load_default
|
28
|
+
@predicate_labels = {
|
29
|
+
eq: 'equals',
|
30
|
+
not_eq: 'not equals',
|
31
|
+
cont: 'contains',
|
32
|
+
in: 'in',
|
33
|
+
not_in: 'not in',
|
34
|
+
}
|
35
|
+
|
36
|
+
@realtime_interval = 30.seconds
|
26
37
|
@disabled_widgets = []
|
27
38
|
end
|
28
39
|
|
data/lib/ahoy_captain/engine.rb
CHANGED
@@ -8,6 +8,27 @@ require 'groupdate'
|
|
8
8
|
require 'pagy'
|
9
9
|
require 'zip'
|
10
10
|
|
11
|
+
module Ransack
|
12
|
+
module Nodes
|
13
|
+
class Condition
|
14
|
+
|
15
|
+
# allows for sql from a formatter
|
16
|
+
# see https://github.com/activerecord-hackery/ransack/issues/702
|
17
|
+
def casted_array?(predicate)
|
18
|
+
return unless predicate.is_a?(Arel::Nodes::Casted)
|
19
|
+
|
20
|
+
predicate.value.is_a?(Array)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Ransack.configure do |config|
|
28
|
+
config.add_predicate 'json_cont', arel_predicate: 'contains', formatter: proc { |v| JSON.parse(v) }
|
29
|
+
config.add_predicate 'json_eq', arel_predicate: 'eq', formatter: proc { |v| JSON.parse(v) }
|
30
|
+
end
|
31
|
+
|
11
32
|
module AhoyCaptain
|
12
33
|
class Engine < Rails::Engine
|
13
34
|
isolate_namespace ::AhoyCaptain
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module AhoyCaptain
|
2
|
+
class FilterConfiguration
|
3
|
+
class Filter
|
4
|
+
attr_reader :column, :label, :url, :predicates, :multiple, :position
|
5
|
+
|
6
|
+
def initialize(label:, column:, url:, predicates: [:in, :not_in], multiple: true, position: nil)
|
7
|
+
@column = column
|
8
|
+
@label = label
|
9
|
+
@url = url
|
10
|
+
@predicates = predicates
|
11
|
+
@multiple = multiple
|
12
|
+
@position = position
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|