How many question would be deleted by roomba if it ignored tags

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT
    PostTags.TagId as TagId,
    COUNT(Posts.Id) as Posts
INTO #Deletes
FROM PostTags
    INNER JOIN Posts ON Posts.Id = PostTags.PostId
WHERE 
    Posts.ClosedDate is null and
    (-- 365-day rule (RemoveAbandondedQuestions)
   ((Posts.Score <= 0 or (Posts.Score <= 1 and Posts.OwnerUserId is null))
    -- has view count <= the age of the question in days times 1.5
    and Posts.ViewCount <= datediff(day, Posts.CreationDate, getdate())*1.5
    -- has too many comments
    and Posts.CommentCount >= 2
   )
  )
  -- has no answers
  and Posts.AnswerCount = 0
  -- post is not locked
  and coalesce((select top 1 PostHistoryTypeId
    from PostHistory
    where PostHistory.PostId = Posts.Id
      and PostHistory.PostHistoryTypeId in (14, 15) -- post locked, unlocked
    order by Id desc), 0) <> 14
  -- post is old
  and datediff(day, Posts.CreationDate, getdate()) > 365
  -- not deleted
  and Posts.DeletionDate is null
GROUP BY PostTags.TagId;


SELECT
    PostTags.TagId as TagId,
    COUNT(Posts.Id) as Posts
INTO #Total    
FROM PostTags
    INNER JOIN Posts ON Posts.Id = PostTags.PostId
WHERE 
  -- post is old
  datediff(day, Posts.CreationDate, getdate()) > 365
  -- not deleted
  and Posts.DeletionDate is null
GROUP BY PostTags.TagId;


SELECT Tags.TagName, #Deletes.Posts, (#Deletes.Posts * 100.0 / #Total.Posts) as [Percent]
FROM #Deletes
    INNER JOIN #Total ON #Deletes.TagId = #Total.TagId
    INNER JOIN Tags on #Deletes.TagId = Tags.Id
ORDER BY #Total.Posts desc;

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results