tkh_search 0.0.4 → 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/app/controllers/search_controller.rb +13 -1
- data/app/controllers/search_stats_controller.rb +10 -0
- data/app/models/tkh_search_event.rb +3 -0
- data/app/views/search_stats/index.html.erb +35 -0
- data/config/routes.rb +1 -0
- data/lib/tkh_search/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd0571508ddad0d7802c5449bb2a3d5cd1de47b7
|
4
|
+
data.tar.gz: 53ac20d7f786dbb2a33fd46f4719418a46e19383
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 907ec49bdefea212c66e917e4ffdedeff0aa9ef6d7f98f3e9bbd3704497925523135a0c49f347241951befce8028137710fd2e09f96c7407afab8a965202a9b5
|
7
|
+
data.tar.gz: cb92a62531f43658a032b6810e606eaa6b217bed9c443279fca0f3a354b2e66db5ef38c170e6dc48b26650ed573be6a40e194b9ec170417b172e9f84fd085e45
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class SearchController < ApplicationController
|
2
2
|
|
3
3
|
def index
|
4
|
-
@query = params[:query].downcase
|
4
|
+
@query = params[:query].downcase.strip
|
5
5
|
@models_to_search = params[:models_to_search].split
|
6
6
|
@results_css_class = params[:results_css_class] || 'js-search-results'
|
7
7
|
token = SecureRandom.base64
|
@@ -28,6 +28,7 @@ class SearchController < ApplicationController
|
|
28
28
|
format.html {}
|
29
29
|
format.js {}
|
30
30
|
end
|
31
|
+
log_search_event
|
31
32
|
end
|
32
33
|
|
33
34
|
def index_all_models
|
@@ -38,4 +39,15 @@ class SearchController < ApplicationController
|
|
38
39
|
redirect_to root_path, notice: "All searchable models have been indexed."
|
39
40
|
end
|
40
41
|
|
42
|
+
private
|
43
|
+
|
44
|
+
def log_search_event
|
45
|
+
if @query.present?
|
46
|
+
search_query = TkhSearchQuery.find_or_create_by( string: @query)
|
47
|
+
search_event = TkhSearchEvent.create(
|
48
|
+
tkh_search_query_id: search_query.id,
|
49
|
+
language: I18n.locale )
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
41
53
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<h1>search statistics</h1>
|
2
|
+
|
3
|
+
<h3>The index ...</h3>
|
4
|
+
|
5
|
+
<p>... has <strong><%= TkhSearchTerm.count %></strong> different search terms pointing to <strong><%= TkhSearchInstance.count %></strong> instances.</p>
|
6
|
+
|
7
|
+
<h3>Total User Searches</h3>
|
8
|
+
|
9
|
+
<table class='table table-striped'>
|
10
|
+
<thead>
|
11
|
+
<tr>
|
12
|
+
<th>last 24 hours</th>
|
13
|
+
<th>last month</th>
|
14
|
+
<th>ever</th>
|
15
|
+
</tr>
|
16
|
+
</thead>
|
17
|
+
|
18
|
+
<tbody>
|
19
|
+
<tr>
|
20
|
+
<td><%= TkhSearchEvent.last_24_hours.count %></td>
|
21
|
+
<td><%= TkhSearchEvent.last_month.count %></td>
|
22
|
+
<td><%= TkhSearchEvent.count %></td>
|
23
|
+
</tr>
|
24
|
+
</tbody>
|
25
|
+
</table>
|
26
|
+
|
27
|
+
<h3>Most Popular Queries in the Last Month</h3>
|
28
|
+
|
29
|
+
<ul>
|
30
|
+
<% TkhSearchEvent.last_month.group(:tkh_search_query_id).order('COUNT(tkh_search_query_id) desc').limit(50).each do |event| %>
|
31
|
+
<li><%= "#{event.tkh_search_query.string} #{TkhSearchEvent.last_month.where(tkh_search_query_id: event.tkh_search_query_id).count}" %></li>
|
32
|
+
<% end %>
|
33
|
+
</ul>
|
34
|
+
|
35
|
+
<%= render 'shared/admin_sidebar' %>
|
data/config/routes.rb
CHANGED
data/lib/tkh_search/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tkh_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Swami Atma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- README.md
|
83
83
|
- Rakefile
|
84
84
|
- app/controllers/search_controller.rb
|
85
|
+
- app/controllers/search_stats_controller.rb
|
85
86
|
- app/models/tkh_search_event.rb
|
86
87
|
- app/models/tkh_search_instance.rb
|
87
88
|
- app/models/tkh_search_query.rb
|
@@ -92,6 +93,7 @@ files:
|
|
92
93
|
- app/views/search/_search_results.html.erb
|
93
94
|
- app/views/search/index.html.erb
|
94
95
|
- app/views/search/index.js.erb
|
96
|
+
- app/views/search_stats/index.html.erb
|
95
97
|
- config/routes.rb
|
96
98
|
- lib/generators/tkh_search/create_or_update_migrations/create_or_update_migrations_generator.rb
|
97
99
|
- lib/generators/tkh_search/create_or_update_migrations/templates/create_tkh_search_events.rb
|