has_searcher 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/app/models/boostificator.rb +12 -25
- data/lib/has_searcher/version.rb +1 -1
- metadata +6 -6
@@ -1,43 +1,30 @@
|
|
1
1
|
class Boostificator
|
2
2
|
MILLIS_IN_YEAR = 1000 * 60 * 60 * 24 * 365
|
3
|
+
PRECISION = 6
|
3
4
|
|
4
5
|
attr_accessor :search, :field
|
5
6
|
|
6
|
-
|
7
|
-
self.search = options[:search]
|
8
|
-
self.field = options[:field]
|
9
|
-
end
|
10
|
-
|
11
|
-
def m
|
12
|
-
1.0 / MILLIS_IN_YEAR
|
13
|
-
end
|
7
|
+
attr_accessor :m, :x, :a, :b
|
14
8
|
|
15
|
-
|
16
|
-
1.1
|
17
|
-
end
|
9
|
+
attr_accessor :now
|
18
10
|
|
19
|
-
def
|
20
|
-
1
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
6
|
11
|
+
def initialize(options)
|
12
|
+
options.reverse_merge!(:a => 1.0, :b => 1.0, :m => 1.0 / MILLIS_IN_YEAR, :now => 1.hour.since.change(:min => 0))
|
13
|
+
options.each do |field, value|
|
14
|
+
self.send("#{field}=", value)
|
15
|
+
end
|
25
16
|
end
|
26
17
|
|
27
18
|
def recip_min
|
28
|
-
sprintf("%f", (recip * 10**
|
19
|
+
sprintf("%f", (recip * 10**PRECISION).floor/10.0**PRECISION)
|
29
20
|
end
|
30
21
|
|
31
22
|
def recip_max
|
32
|
-
sprintf("%f", (recip * 10**
|
23
|
+
sprintf("%f", (recip * 10**PRECISION).ceil/10.0**PRECISION)
|
33
24
|
end
|
34
25
|
|
35
26
|
def recip
|
36
|
-
a / (m*now_ms + b)
|
37
|
-
end
|
38
|
-
|
39
|
-
def now
|
40
|
-
1.hour.since.change(:min => 0)
|
27
|
+
a / (m * now_ms + b)
|
41
28
|
end
|
42
29
|
|
43
30
|
def now_ms
|
@@ -50,7 +37,7 @@ class Boostificator
|
|
50
37
|
|
51
38
|
def adjust_solr_params
|
52
39
|
search.adjust_solr_params do |params|
|
53
|
-
params[:q] = "{!boost b=map(recip(ms(#{now_s},#{field}),#{m},#{a},#{b}),#{recip_min},#{recip_max},1) defType=dismax}#{params[:q]}"
|
40
|
+
params[:q] = "{!boost b=map(recip(ms(#{now_s},#{field}),#{m},#{a},#{b}),#{recip_min},#{recip_max},1) defType=dismax}#{params[:q]}" if params[:q]
|
54
41
|
end
|
55
42
|
end
|
56
43
|
end
|
data/lib/has_searcher/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_searcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &7410960 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *7410960
|
25
25
|
description: ! "This gem adds ability to construct search objects for indexed models.\n
|
26
26
|
\ It works with sunspot, inherited_resources and formtastic"
|
27
27
|
email:
|
@@ -57,7 +57,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
57
|
version: '0'
|
58
58
|
segments:
|
59
59
|
- 0
|
60
|
-
hash: -
|
60
|
+
hash: -3427877683254692333
|
61
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
version: '0'
|
67
67
|
segments:
|
68
68
|
- 0
|
69
|
-
hash: -
|
69
|
+
hash: -3427877683254692333
|
70
70
|
requirements: []
|
71
71
|
rubyforge_project: has_searcher
|
72
72
|
rubygems_version: 1.8.15
|