searchjoy 0.0.10 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 053a6b95d747131d4856e8f1165a4d5d8ea91be2
4
- data.tar.gz: 1619363e231d4be19e7a88ba028cbb8ba8e3a301
3
+ metadata.gz: 718d461a1a5396990820d7317954813740bf68a2
4
+ data.tar.gz: 50c91afedfa3db697f0f94d3bab4bb9911a08355
5
5
  SHA512:
6
- metadata.gz: 533a183daef983d6aaa7d30fece95f66b9c103f3201c592fb71cfe82e05f71220d623d56d0129057013fca8bb952da5dc7aeb363d7b867f94c3832433653c02a
7
- data.tar.gz: 5acb9924124d161c48c908b284fbce60fe191c9de3ebb403b6aeb1d2702c9c2b46281e92ba8af2b5143214c199a825479de4f85c7bea15f7e8ff10ecf1945751
6
+ metadata.gz: 57c03a406ab8d0e6b75fdbda81b519ab02d6b9d00c3a079b32540b6fd6e1e92d6467201db9334733f18fbca3153b46d6f46d0899795426540d5696f32f1a429b
7
+ data.tar.gz: e1a65b650370a3d47458edba0380b7cb2e10795d511da052231d548359db6829d6a1bcb8558a4567421126005b91a8e4c164e0743441e5343421436dcaca690e
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.1.0
2
+
3
+ - Fixed Searchkick integration for `execute: false`
data/README.md CHANGED
@@ -8,7 +8,7 @@ Search analytics made easy
8
8
  - track conversions week over week
9
9
  - monitor the performance of top searches
10
10
 
11
- Works with Rails 3.1+ and any search engine, including Elasticsearch, Sphinx, and Solr
11
+ Works with any search platform, including Elasticsearch, Sphinx, and Solr
12
12
 
13
13
  :cupid: An amazing companion to [Searchkick](https://github.com/ankane/searchkick)
14
14
 
@@ -73,14 +73,14 @@ Next, when a user searches, keep track of the search id. With Searchkick, you ca
73
73
  When a user converts, find the record and call `convert`.
74
74
 
75
75
  ```ruby
76
- search = Searchjoy::Search.find params[:id]
76
+ search = Searchjoy::Search.find(params[:id])
77
77
  search.convert
78
78
  ```
79
79
 
80
80
  Better yet, record the model that converted.
81
81
 
82
82
  ```ruby
83
- item = Item.find params[:item_id]
83
+ item = Item.find(params[:item_id])
84
84
  search.convert(item)
85
85
  ```
86
86
 
@@ -102,7 +102,7 @@ ENV["SEARCHJOY_PASSWORD"] = "secret"
102
102
  In your `config/routes.rb`:
103
103
 
104
104
  ```ruby
105
- authenticate :user, lambda{|user| user.admin? } do
105
+ authenticate :user, -> (user) { user.admin? } do
106
106
  mount Searchjoy::Engine, at: "admin/searchjoy"
107
107
  end
108
108
  ```
@@ -130,7 +130,7 @@ Searchjoy.top_searches = 500 # defaults to 100
130
130
  Show the conversion name in the live stream.
131
131
 
132
132
  ```ruby
133
- Searchjoy.conversion_name = proc{|model| model.name }
133
+ Searchjoy.conversion_name = -> (model) { model.name }
134
134
  ```
135
135
 
136
136
  ## TODO
data/lib/searchjoy.rb CHANGED
@@ -29,13 +29,10 @@ end
29
29
 
30
30
  if defined?(Searchkick)
31
31
  module Searchkick
32
- module Reindex
33
- def self.extended(base)
34
- base.send(:extend, Searchjoy::Track)
35
- method_name = Searchkick.respond_to?(:search_method_name) ? Searchkick.search_method_name : :search
36
- base.define_singleton_method(:search_without_track, base.method(method_name))
37
- base.define_singleton_method(method_name, base.method(:search_with_track))
38
- end
32
+ class Query
33
+ include Searchjoy::Track
34
+ define_method(:execute_without_track, instance_method(:execute))
35
+ define_method(:execute, instance_method(:execute_with_track))
39
36
  end
40
37
 
41
38
  class Results
@@ -1,14 +1,23 @@
1
1
  module Searchjoy
2
2
  module Track
3
- def search_with_track(term, options = {}, &block)
4
- results = search_without_track(term, options) do |body|
5
- block.call(body) if block
6
- end
3
+ def execute_with_track
4
+ results = execute_without_track
7
5
 
8
6
  if options[:track]
9
7
  attributes = options[:track] == true ? {} : options[:track]
10
- results.search = Searchjoy::Search.create({search_type: name, query: term, results_count: results.total_count}.merge(attributes))
8
+
9
+ search_type =
10
+ if klass.respond_to?(:name) && klass.name.present?
11
+ klass.name
12
+ elsif options[:index_name]
13
+ Array(options[:index_name]).map(&:to_s).sort.join(" ")
14
+ else
15
+ "All Indices"
16
+ end
17
+
18
+ results.search = Searchjoy::Search.create({search_type: search_type, query: term, results_count: results.total_count}.merge(attributes))
11
19
  end
20
+
12
21
  results
13
22
  end
14
23
  end
@@ -1,3 +1,3 @@
1
1
  module Searchjoy
2
- VERSION = "0.0.10"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchjoy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-21 00:00:00.000000000 Z
11
+ date: 2016-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chartkick
@@ -102,6 +102,7 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - ".gitignore"
105
+ - CHANGELOG.md
105
106
  - Gemfile
106
107
  - LICENSE.txt
107
108
  - README.md