intel 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -26
- data/app/controllers/intel/searches_controller.rb +1 -8
- data/app/views/intel/searches/index.html.erb +1 -1
- data/app/views/intel/searches/overview.html.erb +2 -2
- data/app/views/intel/searches/recent.html.erb +5 -7
- data/app/views/layouts/intel/application.html.erb +43 -22
- data/lib/intel/search.rb +8 -0
- data/lib/intel/version.rb +1 -1
- data/lib/intel.rb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31879a36e725be72dc34b53afa077f6d2f31bc7b
|
4
|
+
data.tar.gz: 697d5bf3d20c5cc93c5d42df6ab868cb24834df8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e62375f43d6f457a653b9e45c56801620948d0b81a53e55b83a8e7ecd3aa1d69bf42c67f8498c7c994facb9ef0e292446ee5d2ddc53955db8b2437d3bf288b4f
|
7
|
+
data.tar.gz: 9266b4153c82fc6bf57390a5b3143401e2a483b74dbc6129dfde691d3b079aaeff189ae25a218c3f3ccc518ef98bc27061bb452ae8c25cf29e5d38635325490e
|
data/README.md
CHANGED
@@ -63,41 +63,22 @@ It’s that easy.
|
|
63
63
|
|
64
64
|
### Track Conversions
|
65
65
|
|
66
|
-
|
66
|
+
First, choose a conversion metric. At [Instacart](https://www.instacart.com/), an item added to the cart from the search results page counts as a conversion.
|
67
67
|
|
68
|
-
|
68
|
+
Next, when a user searches, keep track of the search id. With Searchkick, you can get the id with `@results.search.id`.
|
69
69
|
|
70
|
-
|
70
|
+
When a user converts, find the record and call `converted`.
|
71
71
|
|
72
72
|
```ruby
|
73
|
-
|
74
|
-
|
73
|
+
search = Intel::Search.find params[:id]
|
74
|
+
search.converted
|
75
75
|
```
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
```ruby
|
80
|
-
search = Intel::Search.find params[:search_id]
|
81
|
-
search.converted_at = Time.now
|
82
|
-
search.save
|
83
|
-
```
|
84
|
-
|
85
|
-
Better yet, record the result that converted.
|
77
|
+
Better yet, record the model that converted.
|
86
78
|
|
87
79
|
```ruby
|
88
80
|
item = Item.find params[:item_id]
|
89
|
-
search.
|
90
|
-
search.save
|
91
|
-
```
|
92
|
-
|
93
|
-
The item will appear in the live stream. Add the `intel_name` method to your model to change what is displayed.
|
94
|
-
|
95
|
-
```ruby
|
96
|
-
class Item < ActiveRecord::Base
|
97
|
-
def intel_name
|
98
|
-
title # use the title method
|
99
|
-
end
|
100
|
-
end
|
81
|
+
search.converted(item)
|
101
82
|
```
|
102
83
|
|
103
84
|
### Authentication
|
@@ -139,6 +120,14 @@ Change the number of top searches shown with:
|
|
139
120
|
Intel.top_searches = 500 # defaults to 100
|
140
121
|
```
|
141
122
|
|
123
|
+
#### Live Conversions
|
124
|
+
|
125
|
+
Show the conversion name in the live stream.
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
Intel.conversion_name = proc{|model| model.name }
|
129
|
+
```
|
130
|
+
|
142
131
|
## TODO
|
143
132
|
|
144
133
|
- customize views
|
@@ -31,15 +31,8 @@ module Intel
|
|
31
31
|
def stream
|
32
32
|
end
|
33
33
|
|
34
|
-
# suspiciously similar to bootstrap 3
|
35
|
-
COLORS = %w[5bc0de d9534f 5cb85c f0ad4e]
|
36
|
-
|
37
34
|
def recent
|
38
35
|
@searches = Intel::Search.order("created_at desc").limit(10)
|
39
|
-
@color = {}
|
40
|
-
@search_types.each_with_index do |search_type, i|
|
41
|
-
@color[search_type] = COLORS[i % COLORS.size]
|
42
|
-
end
|
43
36
|
render layout: false
|
44
37
|
end
|
45
38
|
|
@@ -54,7 +47,7 @@ module Intel
|
|
54
47
|
end
|
55
48
|
|
56
49
|
def set_time_zone
|
57
|
-
@time_zone = Intel.time_zone
|
50
|
+
@time_zone = Intel.time_zone || Time.zone
|
58
51
|
end
|
59
52
|
|
60
53
|
def set_time_range
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<thead>
|
7
7
|
<tr>
|
8
8
|
<th>Top Searches</th>
|
9
|
-
<th class="num"><%= link_to "View all", intel.searches_path(search_type:
|
9
|
+
<th class="num"><%= link_to "View all", intel.searches_path(search_type: @search_type) %></th>
|
10
10
|
</tr>
|
11
11
|
</thead>
|
12
12
|
<tbody>
|
@@ -24,7 +24,7 @@
|
|
24
24
|
<thead>
|
25
25
|
<tr>
|
26
26
|
<th>Low Conversions</th>
|
27
|
-
<th class="num"><%= link_to "View all", intel.searches_path(search_type:
|
27
|
+
<th class="num"><%= link_to "View all", intel.searches_path(search_type: @search_type, sort: "conversion_rate") %></th>
|
28
28
|
</tr>
|
29
29
|
</thead>
|
30
30
|
<tbody>
|
@@ -1,20 +1,18 @@
|
|
1
1
|
<% @searches.each do |search| %>
|
2
2
|
<tr>
|
3
3
|
<td style="width: 15%;">
|
4
|
-
<%= link_to search.search_type, intel.overview_searches_path(search_type: search.search_type), class: "type-link
|
4
|
+
<%= link_to search.search_type, intel.overview_searches_path(search_type: search.search_type), class: "type-link type-link-#{@search_types.index(search.search_type)}" %>
|
5
5
|
</td>
|
6
6
|
<td><%= search.query %></td>
|
7
|
-
<td style="width: 35%;">
|
7
|
+
<td style="width: 35%; color: #5cb85c;">
|
8
8
|
<% if search.converted_at %>
|
9
|
-
<
|
10
|
-
|
11
|
-
<%= search.convertable ? (search.convertable.respond_to?(:intel_name) ? search.convertable.intel_name : "#{search.convertable_type} #{search.convertable_id}") : "Converted" %>
|
12
|
-
</span>
|
9
|
+
<strong>✓</strong>
|
10
|
+
<%= search.convertable ? (Intel.conversion_name ? Intel.conversion_name.call(search.convertable) : "#{search.convertable_type} #{search.convertable_id}") : "Converted" %>
|
13
11
|
<% end %>
|
14
12
|
</td>
|
15
13
|
<td style="width: 20%;" class="num">
|
16
14
|
<%= time_ago_in_words search.created_at %> ago
|
17
|
-
<div
|
15
|
+
<div class="text-muted"><%= pluralize search.results_count, "result" %></div>
|
18
16
|
</td>
|
19
17
|
</tr>
|
20
18
|
<% end %>
|
@@ -40,6 +40,11 @@
|
|
40
40
|
font-size: 20px;
|
41
41
|
}
|
42
42
|
|
43
|
+
h1 small {
|
44
|
+
color: #999;
|
45
|
+
font-weight: normal;
|
46
|
+
}
|
47
|
+
|
43
48
|
h2 {
|
44
49
|
font-size: 16px;
|
45
50
|
}
|
@@ -57,6 +62,10 @@
|
|
57
62
|
border-top: solid 1px #ddd;
|
58
63
|
}
|
59
64
|
|
65
|
+
.text-muted {
|
66
|
+
color: #999;
|
67
|
+
}
|
68
|
+
|
60
69
|
#brand {
|
61
70
|
font-size: 18px;
|
62
71
|
line-height: 20px;
|
@@ -69,15 +78,29 @@
|
|
69
78
|
}
|
70
79
|
|
71
80
|
a.type-link {
|
72
|
-
|
73
|
-
|
74
|
-
|
81
|
+
background-color: #f0ad4e;
|
82
|
+
color: #fff;
|
83
|
+
padding: 8px;
|
84
|
+
border-radius: 4px;
|
75
85
|
}
|
76
86
|
|
77
87
|
a.type-link:hover {
|
78
88
|
text-decoration: none;
|
79
89
|
}
|
80
90
|
|
91
|
+
/* suspiciously similar to bootstrap 3 */
|
92
|
+
a.type-link-0 {
|
93
|
+
background-color: #5bc0de;
|
94
|
+
}
|
95
|
+
|
96
|
+
a.type-link-1 {
|
97
|
+
background-color: #d9534f;
|
98
|
+
}
|
99
|
+
|
100
|
+
a.type-link-2 {
|
101
|
+
background-color: #5cb85c;
|
102
|
+
}
|
103
|
+
|
81
104
|
#header {
|
82
105
|
border-bottom: solid 1px #ddd;
|
83
106
|
padding-bottom: 20px;
|
@@ -262,28 +285,26 @@
|
|
262
285
|
</head>
|
263
286
|
<body>
|
264
287
|
<div class="container">
|
265
|
-
|
266
|
-
<div
|
267
|
-
<div class="
|
268
|
-
<
|
269
|
-
<
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
<li><%= link_to search_type, intel.overview_searches_path(search_type: search_type), class: ("active" if @search_type == search_type) %></li>
|
274
|
-
<% end %>
|
275
|
-
</ul>
|
276
|
-
</div>
|
277
|
-
|
278
|
-
<div class="col-1-2" style="text-align: right;">
|
279
|
-
<% if %w[overview index].include?(params[:action]) and @time_range %>
|
280
|
-
<%= @time_range.first.strftime("%b %-e, %Y") %> to <%= @time_range.last.strftime("%b %-e, %Y") %>
|
281
|
-
<span style="color: #999;"><%= @time_zone.name.sub(" (US & Canada)", "") %></span>
|
288
|
+
<div id="header">
|
289
|
+
<div class="grid">
|
290
|
+
<div class="col-1-2">
|
291
|
+
<ul class="nav">
|
292
|
+
<li id="brand">Intel</li>
|
293
|
+
<li><%= link_to "Live Stream", intel.root_path, class: ("active" if !@search_type) %></li>
|
294
|
+
<% @search_types.each do |search_type| %>
|
295
|
+
<li><%= link_to search_type, intel.overview_searches_path(search_type: search_type), class: ("active" if @search_type == search_type) %></li>
|
282
296
|
<% end %>
|
283
|
-
</
|
297
|
+
</ul>
|
298
|
+
</div>
|
299
|
+
|
300
|
+
<div class="col-1-2" style="text-align: right;">
|
301
|
+
<% if @time_range %>
|
302
|
+
<%= @time_range.first.strftime("%b %-e, %Y") %> to <%= @time_range.last.strftime("%b %-e, %Y") %>
|
303
|
+
<span class="text-muted"><%= @time_zone.name.sub(" (US & Canada)", "") %></span>
|
304
|
+
<% end %>
|
284
305
|
</div>
|
285
306
|
</div>
|
286
|
-
|
307
|
+
</div>
|
287
308
|
|
288
309
|
<%= yield %>
|
289
310
|
</div>
|
data/lib/intel/search.rb
CHANGED
@@ -4,6 +4,14 @@ module Intel
|
|
4
4
|
|
5
5
|
before_save :set_normalized_query
|
6
6
|
|
7
|
+
def converted(convertable = nil)
|
8
|
+
if !converted?
|
9
|
+
self.converted_at = Time.now
|
10
|
+
self.convertable = convertable
|
11
|
+
save(validate: false)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
7
15
|
def converted?
|
8
16
|
converted_at.present?
|
9
17
|
end
|
data/lib/intel/version.rb
CHANGED
data/lib/intel.rb
CHANGED