From 0bb787d987c25856ee332efd221c77ac747339c0 Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 25 Aug 2018 11:26:00 -0500 Subject: [PATCH] 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. --- app/models/post.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 6fa11d74d..227064563 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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