From 11d9b50f3a4ff9cc1d03513c95287c2be842c45c Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg <maxwell@joindiaspora.com> Date: Tue, 10 Apr 2012 00:40:34 -0700 Subject: [PATCH] a solution for a problem with pulling back all visible public ids when querying after much sleuthing, this is an extremely hacky way to limit the amount of public post _ids we are pulling back with every query. previously, for unknown reason, we were pulling back all of them from people you are connected to, and doing giant in queries which were causing bad things to happen. As far as I can tell, we are in fact keeping track of the page( i.e. max time and offset) so there was no need to pull all of them back. This whole file is a huge clusterf*ck, so it really should just get totally refactored, as the stuff that is happening is not really as scary as it looks :( --- app/models/user/querying.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user/querying.rb b/app/models/user/querying.rb index d4c7da6c3f..6db46cac61 100644 --- a/app/models/user/querying.rb +++ b/app/models/user/querying.rb @@ -31,7 +31,7 @@ module User::Querying opts[:by_members_of] ||= self.aspect_ids post_ids = klass.connection.select_values(visible_shareable_sql(klass, opts)).map { |id| id.to_i } - post_ids += klass.connection.select_values(construct_public_followings_sql(opts).to_sql).map {|id| id.to_i } + post_ids += klass.connection.select_values("#{construct_public_followings_sql(opts).to_sql} LIMIT #{opts[:limit]}").map {|id| id.to_i } end def visible_shareable_sql(klass, opts={}) -- GitLab