More optimized and faster query for local public posts
Even faster with new index
This commit is contained in:
parent
2db1d5d641
commit
7fae5ca3b8
1 changed files with 4 additions and 3 deletions
|
|
@ -52,9 +52,10 @@ class Post < ApplicationRecord
|
|||
scope :all_public, -> { where(public: true) }
|
||||
|
||||
scope :all_local_public, -> {
|
||||
left_outer_joins(author: [:pod])
|
||||
.where("pods.host is null") # local posts have no host in pods
|
||||
.where(public: true)
|
||||
where(" exists (
|
||||
select 1 from people where posts.author_id = people.id
|
||||
and people.pod_id is null)
|
||||
and posts.public = true")
|
||||
}
|
||||
|
||||
scope :commented_by, ->(person) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue