Post.pending_or_flagged: fix ambiguous column reference.

Fixes an ambiguous column reference error when searching for
`status:unmoderated` on the comments page:

    https://danbooru.donmai.us/comments?group_by=comment&search[post_tags_match]=status:unmoderated

Also removes the `id in (...)` subquery checking whether flagged posts
have a flag from the last week; this is always true.
This commit is contained in:
evazion
2018-08-25 11:26:00 -05:00
parent e33d6f9e84
commit 0bb787d987

View File

@@ -1618,15 +1618,15 @@ class Post < ApplicationRecord
end
def pending
where("is_pending = ?", true)
where(is_pending: true)
end
def flagged
where("is_flagged = ?", true)
where(is_flagged: true)
end
def pending_or_flagged
where("(is_pending = ? or (is_flagged = ? and id in (select _.post_id from post_flags _ where _.created_at >= ?)))", true, true, 1.week.ago)
pending.or(flagged)
end
def undeleted