ts-datetime-delta 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.textile +5 -5
- data/lib/thinking_sphinx/deltas/datetime_delta.rb +7 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95bf54a85d84a151a5279f2e810eb7090e4e78e9
|
4
|
+
data.tar.gz: e7adca952d3c26d03e3e8e8c0b02d01c40e72aa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 753c0bfdbe857220cc2d318dbcf01b92d4ab6b6e13da59452b23cc0b672790918acec25631e1ebe0955c2a916cffabccd19fe09b8fab60c9ba44854b5c24708d
|
7
|
+
data.tar.gz: c45a214126ca62b0c225311b1431c0fda39bcb45a50b92a69ebdb5e55447d90d12fe1126796165ba700d71ebebf7eca65fce4ccb3ea29c464a3559e0d7c1a6c4
|
data/README.textile
CHANGED
@@ -8,14 +8,14 @@ You'll need Thinking Sphinx 1.3.0 or later (v3 is now supported since the 2.0.0
|
|
8
8
|
|
9
9
|
In your Gemfile, you can use it like so:
|
10
10
|
|
11
|
-
<pre><code>gem 'ts-datetime-delta', '~> 2.0.
|
11
|
+
<pre><code>gem 'ts-datetime-delta', '~> 2.0.1',
|
12
12
|
:require => 'thinking_sphinx/deltas/datetime_delta'</code></pre>
|
13
13
|
|
14
14
|
Or if you're still on Rails 2, then put this in your @environment.rb@ file with the rest of your gem dependencies:
|
15
15
|
|
16
16
|
<pre><code>config.gem 'ts-datetime-delta',
|
17
17
|
:lib => 'thinking_sphinx/deltas/datetime_delta'
|
18
|
-
:version => '>= 2.0.
|
18
|
+
:version => '>= 2.0.1'</code></pre>
|
19
19
|
|
20
20
|
No matter which version of Rails, you'll need to add the following line to the bottom of your @Rakefile@:
|
21
21
|
|
@@ -40,14 +40,14 @@ But for Thinking Sphinx v1/v2, it belongs within your @define_index@ blocks:
|
|
40
40
|
set_property :delta => :datetime
|
41
41
|
end</code></pre>
|
42
42
|
|
43
|
-
If you want to use a column other than @updated_at@, you can specify it using the @:
|
43
|
+
If you want to use a column other than @updated_at@, you can specify it using the @:column@ option. The same goes for the threshold, which defaults to one day.
|
44
44
|
|
45
45
|
Again, Thinking Sphinx v3 expects these options outside the block:
|
46
46
|
|
47
47
|
<pre><code>ThinkingSphinx::Index.define(:book,
|
48
48
|
:with => :active_record,
|
49
49
|
:delta => ThinkingSphinx::Deltas::DatetimeDelta,
|
50
|
-
:delta_options => {:threshold => 1.hour, :
|
50
|
+
:delta_options => {:threshold => 1.hour, :column => :changed_at}
|
51
51
|
) do
|
52
52
|
# ...
|
53
53
|
end</code></pre>
|
@@ -56,7 +56,7 @@ But Thinking Sphinx v1/v2 it goes within the @define_index@ block:
|
|
56
56
|
|
57
57
|
<pre><code>set_property :delta => :datetime,
|
58
58
|
:threshold => 1.hour,
|
59
|
-
:
|
59
|
+
:column => :changed_at</code></pre>
|
60
60
|
|
61
61
|
Then, while your Rails application is running, you'll need to run the delta indexing rake task regularly - as often as your threshold, allowing for some time for the indexing to actually happen.
|
62
62
|
|
@@ -13,7 +13,7 @@ class ThinkingSphinx::Deltas::DatetimeDelta < ThinkingSphinx::Deltas::DefaultDel
|
|
13
13
|
attr_reader :adapter
|
14
14
|
|
15
15
|
def self.index
|
16
|
-
if
|
16
|
+
if thinking_sphinx_v2?
|
17
17
|
ThinkingSphinx.context.indexed_models.collect { |model|
|
18
18
|
model.constantize
|
19
19
|
}.select { |model|
|
@@ -39,6 +39,10 @@ class ThinkingSphinx::Deltas::DatetimeDelta < ThinkingSphinx::Deltas::DefaultDel
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
def self.thinking_sphinx_v2?
|
43
|
+
ThinkingSphinx.respond_to?(:sphinx_pid)
|
44
|
+
end
|
45
|
+
|
42
46
|
# Initialises the Delta object for the given index and settings. All handled
|
43
47
|
# by Thinking Sphinx, so you shouldn't need to call this method yourself in
|
44
48
|
# general day-to-day situations.
|
@@ -46,7 +50,7 @@ class ThinkingSphinx::Deltas::DatetimeDelta < ThinkingSphinx::Deltas::DefaultDel
|
|
46
50
|
# For TS v2: the index
|
47
51
|
# For TS v3: the database adapter
|
48
52
|
def initialize(arg, options = {})
|
49
|
-
if
|
53
|
+
if self.class.thinking_sphinx_v2?
|
50
54
|
@index = arg
|
51
55
|
else # Thinking Sphinx v3
|
52
56
|
@adapter = arg
|
@@ -78,7 +82,7 @@ class ThinkingSphinx::Deltas::DatetimeDelta < ThinkingSphinx::Deltas::DefaultDel
|
|
78
82
|
#
|
79
83
|
def delayed_index(arg)
|
80
84
|
config = ThinkingSphinx::Configuration.instance
|
81
|
-
if
|
85
|
+
if self.class.thinking_sphinx_v2?
|
82
86
|
model = arg
|
83
87
|
rotate = ThinkingSphinx.sphinx_running? ? " --rotate" : ""
|
84
88
|
output = `#{config.bin_path}#{config.indexer_binary_name} --config #{config.config_file}#{rotate} #{model.delta_index_names.join(' ')}`
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ts-datetime-delta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Allan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thinking-sphinx
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.2.2
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Thinking Sphinx - Datetime Deltas
|