Closed question roomba


Please login or register to vote for this query.

(click on this box to dismiss)

With great power comes great responsibility. See The check for reopen votes is usually too conservative, but votes should expire after 14 days at the most. This query excludes questions that are duplicate targets, even though the roomba would be willing to delete them.


Q&A for professional and amateur woodworkers

--MaxQScore: Max Question Score
declare @qscore int = ##MaxQScore:int?1##
--MaxAScore: Max Answer Score
declare @ascore int = ##MaxAScore:int?1##
declare @now datetime = getdate()

select distinct top ##Top:int?200##
  p.Id as [Post Link],
  max(a.Score) as [Best Answer],
from Posts p
-- find edits from the past 9 days
left join PostHistory ph on ph.postid =
  and datediff(d, ph.CreationDate, @now) <= 9
-- find reopen votes cast in the last 14 days
left join Votes v on v.PostId = p.Id and v.VoteTypeId = '7'
  and datediff(d, v.CreationDate, @now) <= 14
left join Posts a on p.Id = a.ParentId
  -- question was closed more than 9 days ago
  p.ClosedDate is not null
  and datediff(d, p.ClosedDate, @now) > 9
  -- not closed as a duplicate
  and (select top 1 Comment
   from PostHistory ph
   where ph.PostId = p.Id and PostHistoryTypeId = 10
   order by Id desc) not in (1, 101)
  and p.Score <= @qscore
  -- is not locked
  and coalesce((select top 1 PostHistoryTypeId
    from PostHistory
    where PostHistory.PostId = p.Id
      and PostHistory.PostHistoryTypeId in (14, 15) -- post locked, unlocked
    order by Id desc), 0) <> 14
  and p.AcceptedAnswerId is null
  and (p.Score > 0 or a.Score > 0)
group by p.Id, p.Score, p.CreationDate, p.ViewCount--, crt.Name
having coalesce(max(a.Score),0) <= @ascore
  and count(ph.Id) = 0 -- no recent edits
  and count(v.Id) = 0 -- no recent reopen votes
order by p.Score, max(a.Score), CreationDate

select @now as [Time of query]

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results