Active 0.0.17 → 0.0.18
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.
- data/lib/services/search.rb +14 -2
- data/spec/search_memcached_spec.rb +15 -22
- data/spec/search_spec.rb +1 -1
- data/version.txt +1 -1
- metadata +3 -3
data/lib/services/search.rb
CHANGED
@@ -239,8 +239,13 @@ module Active
|
|
239
239
|
@searchTime = parsed_json["searchTime"]
|
240
240
|
@numberOfResults = parsed_json["numberOfResults"]
|
241
241
|
@results = parsed_json['_results'].collect { |a| Activity.new(GSA.new(a)) }
|
242
|
+
|
243
|
+
begin
|
244
|
+
Active.CACHE.set( Digest::MD5.hexdigest(end_point), self) if Active.CACHE
|
245
|
+
rescue Exception => e
|
246
|
+
end
|
247
|
+
|
242
248
|
|
243
|
-
Active.CACHE.set( Digest::MD5.hexdigest(end_point), self) if Active.CACHE
|
244
249
|
|
245
250
|
rescue JSON::ParserError => e
|
246
251
|
raise RuntimeError, "JSON::ParserError json=#{res.body}"
|
@@ -302,7 +307,14 @@ module Active
|
|
302
307
|
|
303
308
|
def self.return_cached key
|
304
309
|
if Active.CACHE
|
305
|
-
|
310
|
+
begin
|
311
|
+
cached_version = Active.CACHE.get(key)
|
312
|
+
rescue Exception => e
|
313
|
+
return nil
|
314
|
+
end
|
315
|
+
|
316
|
+
|
317
|
+
|
306
318
|
if cached_version
|
307
319
|
puts "Active Search [CACHE] #{key}"
|
308
320
|
return cached_version
|
@@ -6,44 +6,37 @@ require File.join(File.dirname(__FILE__), %w[custom_matchers_spec])
|
|
6
6
|
require File.join(File.dirname(__FILE__), %w[ .. lib services search])
|
7
7
|
require File.join(File.dirname(__FILE__), %w[ .. lib services activity])
|
8
8
|
include Active::Services
|
9
|
-
|
9
|
+
|
10
10
|
|
11
11
|
describe Search do
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
after(:each) do
|
13
|
+
begin
|
14
|
+
Active.CACHE.flush() if Active.CACHE
|
15
|
+
rescue Exception => e
|
16
|
+
end
|
17
|
+
Active.memcache_host(nil)
|
15
18
|
end
|
16
|
-
it "
|
19
|
+
it "should search by city" do
|
20
|
+
Active.memcache_host("localhost:11211")
|
17
21
|
s = Search.search({:city=>"Oceanside"})
|
18
22
|
s.city.should eql("Oceanside")
|
19
23
|
s.results.should_not be_nil
|
20
24
|
s.results.should have_at_least(1).items
|
21
|
-
|
22
25
|
Active.CACHE.get('ce16c9ef2b618d0d5a88d46933109e4d').results.length.should eql(10)
|
23
|
-
|
24
26
|
s = Search.search({:city=>"Oceanside"})
|
25
27
|
s.city.should eql("Oceanside")
|
26
28
|
s.results.should_not be_nil
|
27
29
|
s.results.should have_at_least(1).items
|
28
|
-
|
29
30
|
end
|
30
|
-
|
31
|
+
it "should be fail safe" do
|
32
|
+
Active.memcache_host("fake:11211")
|
33
|
+
s = Search.search({:city=>"Oceanside"})
|
34
|
+
s.city.should eql("Oceanside")
|
35
|
+
s.results.should have_at_least(1).items
|
36
|
+
end
|
31
37
|
end
|
32
38
|
|
33
39
|
|
34
40
|
|
35
41
|
|
36
42
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
data/spec/search_spec.rb
CHANGED
@@ -5,7 +5,7 @@ require File.join(File.dirname(__FILE__), %w[custom_matchers_spec])
|
|
5
5
|
require File.join(File.dirname(__FILE__), %w[ .. lib services search])
|
6
6
|
require File.join(File.dirname(__FILE__), %w[ .. lib services activity])
|
7
7
|
include Active::Services
|
8
|
-
Active.memcache_host "localhost:11211"
|
8
|
+
# Active.memcache_host "localhost:11211"
|
9
9
|
|
10
10
|
describe Search do
|
11
11
|
include CustomMatchers
|
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.18
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Active
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 18
|
10
|
+
version: 0.0.18
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jonathan Spooner, Brian Levine
|