Prevent protecting questions under certain circumstances

0

Please login or register to vote for this query.

(click on this box to dismiss)

http://meta.stackexchange.com/questions/274324/prevent-protecting-questions-under-certain-circumstances

Stack Overflow

Q&A for professional and enthusiast programmers

select p.id as [Post Link]
     , p.answercount
from posts p
inner join posthistory ph on ph.postid = p.id
-- remove the next line if you don't care about deleted answers
left outer join postswithdeleted delans on delans.parentid = p.id
where ph.posthistorytypeid = 19 -- protect
and p.posttypeid = 1 -- Q
and p.answercount = 0 
and p.closeddate is null -- closed > protect accordimng to ShadowWizard
and not exists (select 1 
                from posthistory pu 
                where pu.postid = p.id
                and pu.posthistorytypeid = 20 -- unprotect
                and pu.creationdate > ph.creationdate)
-- remove the next line if you don't care about deleted answers
and delans.id is null

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results