searchjoy 0.0.7 → 0.0.8

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: 8829cfdcf0e99e13e962d499ac5fd3ef086e9aff
4
- data.tar.gz: f231ac45644bbd7e3b2e1933500bc028dc8723e2
3
+ metadata.gz: 286338a56506c0efe7a8499ca70e68217d722b97
4
+ data.tar.gz: 5cf770afd4da14880dde412dd83fd1c23d8299cf
5
5
  SHA512:
6
- metadata.gz: 42a8ecb79f3a0ec02f27c892ee28d1cf28b9df9670280955577b81e95497052384ef0a620e2bbad92039b14f20baab8117f8d8ca07efc242696b338424a9af0b
7
- data.tar.gz: 0c8974a26e7f0d5a2720569651eeb3c03e27c992c72a0f492737f001c2c88886176463c49b799ed2b0f8c5d46ee418ba45ad1cf51e4eb1c22ced56c920d26fac
6
+ metadata.gz: 08117e05a6809313e7dab569a0b928cc744a124e81845019726576b6d05e5d11bf86169f894ffca4237490ae29eade9f2f41f1b778917100166cfb1813e077e0
7
+ data.tar.gz: 52d5431f207d5e3b13576aeb3f298cce732995eadd1c1d9fa958af1bb6b1f2724d6ce5f261b3ee1c510d3d20829ceb09ae7e6927c56e9b9636eaead80f12c59f
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in searchjoy.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -12,7 +12,7 @@ Works with Rails 3.1+ and any search engine, including Elasticsearch, Sphinx, an
12
12
 
13
13
  :cupid: An amazing companion to [Searchkick](https://github.com/ankane/searchkick)
14
14
 
15
- :tangerine: Battle-tested at [Instacart](https://www.instacart.com)
15
+ :tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
16
16
 
17
17
  ## Get Started
18
18
 
@@ -45,14 +45,15 @@ Track searches by creating a record in the database.
45
45
  Searchjoy::Search.create(
46
46
  search_type: "Item", # typically the model name
47
47
  query: "apple",
48
- results_count: 12
48
+ results_count: 12,
49
+ user_id: 1
49
50
  )
50
51
  ```
51
52
 
52
53
  With [Searchkick](https://github.com/ankane/searchkick), you can use the `track` option to do this automatically.
53
54
 
54
55
  ```ruby
55
- Item.search "apple", track: true
56
+ Item.search "apple", track: {user_id: 1}
56
57
  ```
57
58
 
58
59
  If you want to track more attributes, add them to the `searchjoy_searches` table. Then, pass the values to the `track` option.
@@ -12,7 +12,7 @@ module Searchjoy
12
12
 
13
13
  def index
14
14
  if params[:sort] == "conversion_rate"
15
- @searches.sort_by!{|s| [s["conversion_rate"].to_f, s["query"]] }
15
+ @searches.sort_by! { |s| [s["conversion_rate"].to_f, s["query"]] }
16
16
  end
17
17
  end
18
18
 
@@ -21,7 +21,7 @@ module Searchjoy
21
21
  @searches_by_week = relation.group_by_week(:created_at, Time.zone, @time_range).count
22
22
  @conversions_by_week = relation.where("converted_at is not null").group_by_week(:created_at, Time.zone, @time_range).count
23
23
  @top_searches = @searches.first(5)
24
- @bad_conversion_rate = @searches.sort_by{|s| [s["conversion_rate"].to_f, s["query"]] }.first(5).select{|s| s["conversion_rate"] < 50 }
24
+ @bad_conversion_rate = @searches.sort_by { |s| [s["conversion_rate"].to_f, s["query"]] }.first(5).select { |s| s["conversion_rate"] < 50 }
25
25
  @conversion_rate_by_week = {}
26
26
  @searches_by_week.each do |week, searches_count|
27
27
  @conversion_rate_by_week[week] = searches_count > 0 ? (100.0 * @conversions_by_week[week] / searches_count).round : 0
@@ -1,6 +1,7 @@
1
1
  class <%= migration_class_name %> < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :searchjoy_searches do |t|
4
+ t.integer :user_id
4
5
  t.string :search_type
5
6
  t.string :query
6
7
  t.string :normalized_query
@@ -3,14 +3,14 @@ module Searchjoy
3
3
  belongs_to :convertable, polymorphic: true
4
4
 
5
5
  # the devise way
6
- if Rails::VERSION::MAJOR == 3 and !defined?(ActionController::StrongParameters)
6
+ if (Rails::VERSION::MAJOR == 3 && !defined?(ActionController::StrongParameters)) || defined?(ActiveModel::MassAssignmentSecurity)
7
7
  attr_accessible :search_type, :query, :results_count
8
8
  end
9
9
 
10
10
  before_save :set_normalized_query
11
11
 
12
12
  def convert(convertable = nil)
13
- if !converted?
13
+ unless converted?
14
14
  self.converted_at = Time.now
15
15
  self.convertable = convertable
16
16
  save(validate: false)
@@ -26,6 +26,5 @@ module Searchjoy
26
26
  def set_normalized_query
27
27
  self.normalized_query = query.downcase if query
28
28
  end
29
-
30
29
  end
31
30
  end
@@ -1,16 +1,14 @@
1
1
  module Searchjoy
2
2
  module Track
3
-
4
3
  def search_with_track(term, options = {})
5
4
  results = search_without_track(term, options)
6
5
 
7
6
  if options[:track]
8
7
  attributes = options[:track] == true ? {} : options[:track]
9
- results.search = Searchjoy::Search.create({search_type: self.name, query: term, results_count: results.total_count}.merge(attributes))
8
+ results.search = Searchjoy::Search.create({search_type: name, query: term, results_count: results.total_count}.merge(attributes))
10
9
  end
11
10
 
12
11
  results
13
12
  end
14
-
15
13
  end
16
14
  end
@@ -1,3 +1,3 @@
1
1
  module Searchjoy
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
data/searchjoy.gemspec CHANGED
@@ -1,19 +1,19 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'searchjoy/version'
4
+ require "searchjoy/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "searchjoy"
8
8
  spec.version = Searchjoy::VERSION
9
9
  spec.authors = ["Andrew Kane"]
10
10
  spec.email = ["andrew@chartkick.com"]
11
- spec.description = %q{Search analytics made easy}
12
- spec.summary = %q{Search analytics made easy}
11
+ spec.description = "Search analytics made easy"
12
+ spec.summary = "Search analytics made easy"
13
13
  spec.homepage = "https://github.com/ankane/searchjoy"
14
14
  spec.license = "MIT"
15
15
 
16
- spec.files = `git ls-files`.split($/)
16
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
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.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-18 00:00:00.000000000 Z
11
+ date: 2015-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chartkick
@@ -113,9 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  requirements: []
115
115
  rubyforge_project:
116
- rubygems_version: 2.2.2
116
+ rubygems_version: 2.4.5.1
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: Search analytics made easy
120
120
  test_files: []
121
- has_rdoc: