searchjoy 0.0.10 → 0.1.0
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/CHANGELOG.md +3 -0
- data/README.md +5 -5
- data/lib/searchjoy.rb +4 -7
- data/lib/searchjoy/track.rb +14 -5
- data/lib/searchjoy/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 718d461a1a5396990820d7317954813740bf68a2
|
4
|
+
data.tar.gz: 50c91afedfa3db697f0f94d3bab4bb9911a08355
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57c03a406ab8d0e6b75fdbda81b519ab02d6b9d00c3a079b32540b6fd6e1e92d6467201db9334733f18fbca3153b46d6f46d0899795426540d5696f32f1a429b
|
7
|
+
data.tar.gz: e1a65b650370a3d47458edba0380b7cb2e10795d511da052231d548359db6829d6a1bcb8558a4567421126005b91a8e4c164e0743441e5343421436dcaca690e
|
data/CHANGELOG.md
ADDED
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
|
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
|
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
|
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,
|
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 =
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
data/lib/searchjoy/track.rb
CHANGED
@@ -1,14 +1,23 @@
|
|
1
1
|
module Searchjoy
|
2
2
|
module Track
|
3
|
-
def
|
4
|
-
results =
|
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
|
-
|
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
|
data/lib/searchjoy/version.rb
CHANGED
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
|
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-
|
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
|