From 0a124acdf0cb141563733aa822dea52515ad19c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Sat, 16 Feb 2013 23:42:23 +0100 Subject: [PATCH] Revert "fix regression from #3968" Revert "Merge pull request #3968 from marpo60/limit_shareable_from_person_queries" This reverts commit ddfc558a9b5d6ed19e89b7a6ad9ecf0dc4ebb8f9. This reverts commit 30ed4b4e70f4768b310e94670f644e593a47e34f, reversing changes made to f50ce2cb1d392a2f6fdb9bf99621634800306426. limiting the fetch of the IDs breaks paginating, there's no quick way to fix that I left the spec in for future use. --- Changelog.md | 1 - lib/evil_query.rb | 12 ++++++++---- spec/lib/stream/person_spec.rb | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Changelog.md b/Changelog.md index dd4219a42..4c436dec0 100644 --- a/Changelog.md +++ b/Changelog.md @@ -16,7 +16,6 @@ * Ported aspects to backbone [#3850](https://github.com/diaspora/diaspora/pull/3850) * Join tagging's table instead of tags to improve a bit the query [#3932](https://github.com/diaspora/diaspora/pull/3932) * Refactor contacts/index view [#3937](https://github.com/diaspora/diaspora/pull/3937) -* Limit queries in ShareablesFromPerson [#3968](https://github.com/diaspora/diaspora/pull/3968) ## Features diff --git a/lib/evil_query.rb b/lib/evil_query.rb index 13df0b981..0753b0e0c 100644 --- a/lib/evil_query.rb +++ b/lib/evil_query.rb @@ -116,12 +116,16 @@ module EvilQuery def make_relation! return querents_posts if @person == @querent.person + # persons_private_visibilities and persons_public_posts have no limit which is making shareable_ids gigantic. + # perhaps they should the arrays should be merged and sorted + # then the query at the bottom of this method can be paginated or something? + shareable_ids = contact.present? ? fetch_ids!(persons_private_visibilities, "share_visibilities.shareable_id") : [] shareable_ids += fetch_ids!(persons_public_posts, table_name + ".id") @class.where(:id => shareable_ids, :pending => false). - select('DISTINCT ' + table_name + '.*'). - order(table_name + ".created_at DESC") + select('DISTINCT '+table_name+'.*'). + order(table_name+".created_at DESC") end protected @@ -139,11 +143,11 @@ module EvilQuery end def persons_private_visibilities - contact.share_visibilities.where(:hidden => false, :shareable_type => @class.to_s).order("created_at DESC").limit(15) + contact.share_visibilities.where(:hidden => false, :shareable_type => @class.to_s) end def persons_public_posts - @person.send(table_name).where(:public => true).select(table_name + '.id').order("created_at DESC").limit(15) + @person.send(table_name).where(:public => true).select(table_name+'.id') end end end diff --git a/spec/lib/stream/person_spec.rb b/spec/lib/stream/person_spec.rb index ddc69a5e4..d29d7dbe8 100644 --- a/spec/lib/stream/person_spec.rb +++ b/spec/lib/stream/person_spec.rb @@ -29,4 +29,5 @@ describe Stream::Person do fetched_posts.should == posts end + end