tkh_search 0.1 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +6 -0
- data/README.md +5 -0
- data/app/controllers/search_controller.rb +2 -2
- data/app/models/tkh_search_instance.rb +1 -1
- data/app/views/search/_search_results.html.erb +2 -2
- data/lib/generators/tkh_search/create_or_update_migrations/create_or_update_migrations_generator.rb +1 -0
- data/lib/generators/tkh_search/create_or_update_migrations/templates/fix_dangerous_attributes.rb +16 -0
- data/lib/tkh_search/tkh_searchable.rb +2 -2
- data/lib/tkh_search/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ec2548d73c8962999cf9eb77004b5ab2da38126
|
4
|
+
data.tar.gz: 03f8807ddfca834983c47a36e9012777ec1eda0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36f41316f96bf10a0ee22e4f088228665031774f6f624d199178207f924802ad98800d20f13d616d3d41f633d7709b1be4124c48c18bb85b9640ce77c4e6f09f
|
7
|
+
data.tar.gz: 7012552fcf9027737a3e89c4b674214ce8e437140a76d40de9da8a9a13bf6be2a759a6e1fb306aa638a264c5eb5ecc5616fa9c9c3f7b18408801126f2a688e99
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -118,6 +118,11 @@ This can also be used for the sake of localization
|
|
118
118
|
<%= render 'search/search_form', models_to_search: 'Event', submit_label: 'find an awesome event' %>
|
119
119
|
```
|
120
120
|
|
121
|
+
## Search Stats
|
122
|
+
|
123
|
+
Administrators can see the indexing and searching stats at
|
124
|
+
|
125
|
+
/search_stats
|
121
126
|
|
122
127
|
## Missing Features
|
123
128
|
|
@@ -12,10 +12,10 @@ class SearchController < ApplicationController
|
|
12
12
|
search_terms.each do |search_term|
|
13
13
|
if search_term.tkh_search_instances.any?
|
14
14
|
search_term.tkh_search_instances.each do |search_instance|
|
15
|
-
if @models_to_search.include? search_instance.
|
15
|
+
if @models_to_search.include? search_instance.host_model_name
|
16
16
|
search_result = TkhSearchResult.find_or_create_by(
|
17
17
|
token: token,
|
18
|
-
|
18
|
+
host_model_name: search_instance.host_model_name,
|
19
19
|
model_record_id: search_instance.model_record_id)
|
20
20
|
search_result.rating += search_instance.rating
|
21
21
|
search_result.save
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<ul class="search-results">
|
2
2
|
<% if search_results.any? %>
|
3
3
|
<% search_results.each do |result| %>
|
4
|
-
<% record = (Kernel.const_get result.
|
4
|
+
<% record = (Kernel.const_get result.host_model_name).find(result.model_record_id) %>
|
5
5
|
<% if defined? record.name %>
|
6
6
|
<% link_label = record.name %>
|
7
7
|
<% elsif defined? record.title %>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<% link_label = 'no title or name' %>
|
11
11
|
<% end %>
|
12
12
|
<%= content_tag :li,
|
13
|
-
"<span class='sr-model-name'>#{result.
|
13
|
+
"<span class='sr-model-name'>#{result.host_model_name}</span> -
|
14
14
|
<span class='sr-record-link'>#{link_to link_label, record}</span> -
|
15
15
|
<span class='sr-rating'>#{result.rating}</span>
|
16
16
|
".html_safe
|
data/lib/generators/tkh_search/create_or_update_migrations/create_or_update_migrations_generator.rb
CHANGED
@@ -22,6 +22,7 @@ module TkhSearch
|
|
22
22
|
migration_template "create_tkh_search_queries.rb", "db/migrate/create_tkh_search_queries.rb"
|
23
23
|
migration_template "create_tkh_search_events.rb", "db/migrate/create_tkh_search_events.rb"
|
24
24
|
migration_template "create_tkh_search_results.rb", "db/migrate/create_tkh_search_results.rb"
|
25
|
+
migration_template "fix_dangerous_attributes.rb", "db/migrate/fix_dangerous_attributes.rb"
|
25
26
|
end
|
26
27
|
|
27
28
|
end
|
data/lib/generators/tkh_search/create_or_update_migrations/templates/fix_dangerous_attributes.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
class FixDangerousAttributes < ActiveRecord::Migration
|
2
|
+
|
3
|
+
# ActiveRecord raises an exception if some model attributes
|
4
|
+
# use the same word as some AR methods or attributes.
|
5
|
+
|
6
|
+
def self.up
|
7
|
+
rename_column :tkh_search_instances, :model_name, :host_model_name
|
8
|
+
rename_column :tkh_search_results, :model_name, :host_model_name
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
rename_column :tkh_search_instances, :host_model_name, :model_name
|
13
|
+
rename_column :tkh_search_results, :host_model_name, :model_name
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -53,7 +53,7 @@ module TkhSearch
|
|
53
53
|
words.each do |word,strength|
|
54
54
|
term = TkhSearchTerm.find_or_create_by( word: word )
|
55
55
|
instance = TkhSearchInstance.find_or_create_by(
|
56
|
-
|
56
|
+
host_model_name: self.name,
|
57
57
|
model_record_id: record.id,
|
58
58
|
tkh_search_term_id: term.id )
|
59
59
|
instance.rating = strength
|
@@ -75,7 +75,7 @@ module TkhSearch
|
|
75
75
|
def remove_obsolete_instances
|
76
76
|
# after an individual record save and the record has been reindexed
|
77
77
|
# we need to remove indexed instances for words which have been deleted
|
78
|
-
obsolete_instances = TkhSearchInstance.where( '
|
78
|
+
obsolete_instances = TkhSearchInstance.where( 'host_model_name = ? and model_record_id = ?', self.class.name, self.id ).a_bit_old
|
79
79
|
obsolete_instances.each do |instance|
|
80
80
|
instance.destroy!
|
81
81
|
end
|
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.2'
|
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-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- lib/generators/tkh_search/create_or_update_migrations/templates/create_tkh_search_queries.rb
|
102
102
|
- lib/generators/tkh_search/create_or_update_migrations/templates/create_tkh_search_results.rb
|
103
103
|
- lib/generators/tkh_search/create_or_update_migrations/templates/create_tkh_search_terms.rb
|
104
|
+
- lib/generators/tkh_search/create_or_update_migrations/templates/fix_dangerous_attributes.rb
|
104
105
|
- lib/generators/tkh_search/install_initializer/install_initializer_generator.rb
|
105
106
|
- lib/generators/tkh_search/install_initializer/templates/tkh_search.rb
|
106
107
|
- lib/tasks/tkh_search_tasks.rake
|
@@ -128,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
129
|
version: '0'
|
129
130
|
requirements: []
|
130
131
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
132
|
+
rubygems_version: 2.4.4
|
132
133
|
signing_key:
|
133
134
|
specification_version: 4
|
134
135
|
summary: Lightweigh Rails search engine
|