Merge pull request #3968 from marpo60/limit_shareable_from_person_queries
limit ShareablesFromPerson queries to improve performance
This commit is contained in:
commit
30ed4b4e70
2 changed files with 5 additions and 8 deletions
|
|
@ -16,6 +16,7 @@
|
||||||
* Ported aspects to backbone [#3850](https://github.com/diaspora/diaspora/pull/3850)
|
* 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)
|
* 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)
|
* 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
|
## Features
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,10 +116,6 @@ module EvilQuery
|
||||||
def make_relation!
|
def make_relation!
|
||||||
return querents_posts if @person == @querent.person
|
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 = contact.present? ? fetch_ids!(persons_private_visibilities, "share_visibilities.shareable_id") : []
|
||||||
shareable_ids += fetch_ids!(persons_public_posts, table_name + ".id")
|
shareable_ids += fetch_ids!(persons_public_posts, table_name + ".id")
|
||||||
|
|
||||||
|
|
@ -143,11 +139,11 @@ module EvilQuery
|
||||||
end
|
end
|
||||||
|
|
||||||
def persons_private_visibilities
|
def persons_private_visibilities
|
||||||
contact.share_visibilities.where(:hidden => false, :shareable_type => @class.to_s)
|
contact.share_visibilities.where(:hidden => false, :shareable_type => @class.to_s).limit(15)
|
||||||
end
|
end
|
||||||
|
|
||||||
def persons_public_posts
|
def persons_public_posts
|
||||||
@person.send(table_name).where(:public => true).select(table_name+'.id')
|
@person.send(table_name).where(:public => true).select(table_name + '.id').limit(15)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue