Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxwell Salzberg <maxwell@joindiaspora.com>2011-11-08 07:52:48 +0400
committerMaxwell Salzberg <maxwell@joindiaspora.com>2011-11-08 07:52:48 +0400
commitfe3fe0f5cc072a13581a525c5b4a5d8c6bdf503e (patch)
tree6abb8c173792ee4c537675df8d689d414bda387e
parent0f19076b4099f0981abe5736ba6071c8efbcaf2d (diff)
MS SM save sync cache if you have some sort of contacts
-rw-r--r--lib/diaspora/user/querying.rb7
-rw-r--r--spec/models/user/querying_spec.rb6
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb
index a93370f9d..fea5c6e4b 100644
--- a/lib/diaspora/user/querying.rb
+++ b/lib/diaspora/user/querying.rb
@@ -28,7 +28,11 @@ module Diaspora
if use_cache?(opts)
cache = RedisCache.new(self, opts[:order_field])
- #cache.ensure_populated!(opts)
+ #total hax
+ if self.contacts.where(:sharing => true, :receiving => true).count > 0
+ cache.ensure_populated!(opts)
+ end
+
name = klass.to_s.downcase
shareable_ids = cache.send(name+"_ids", opts[:max_time], opts[:limit] +1)
end
@@ -159,6 +163,7 @@ module Diaspora
protected
# @return [Boolean]
+
def use_cache?(opts)
RedisCache.configured? && RedisCache.supported_order?(opts[:order_field]) && opts[:all_aspects?].present?
end
diff --git a/spec/models/user/querying_spec.rb b/spec/models/user/querying_spec.rb
index 2101d662e..d70b9500a 100644
--- a/spec/models/user/querying_spec.rb
+++ b/spec/models/user/querying_spec.rb
@@ -102,8 +102,10 @@ describe User do
AppConfig[:redis_cache] = nil
end
- it "kicks off a job that will populate the latest 100 posts" do
- pending "we need a job for this - ensure_populated! is too costly to do synchronously for new users"
+ it "populates the cache if the user has a mutual contact" do
+ RedisCache.any_instance.should_receive(:ensure_populated!)
+ alice.stub(:use_cache?).and_return(true)
+ alice.visible_shareable_ids(Post)
end
it 'does not get used if if all_aspects? option is not present' do