How many Copy Editor/Strunk & White-qualifying edits have I made?

1

Please login or register to vote for this query.

(click on this box to dismiss)

Mathematics

Q&A for people studying math at any level and professionals in related fields

-- Copied from http://data.stackexchange.com/stackoverflow/query/fork/35999
-- How many Copy Editor/Strunk & White-qualifying edits have I made?
-- Counts the number of title and/or body revisions you've made
-- on other people's non-deleted posts.

DECLARE @UserId int = ##UserId##

SELECT COUNT(DISTINCT ph.RevisionGUID)
    FROM PostHistory ph
    WHERE
        ph.UserId = @UserId AND
        ph.PostHistoryTypeId IN (4, 5) AND
        ph.PostId NOT IN (SELECT p.Id FROM Posts p WHERE p.OwnerUserId = @UserId)

-- Copied from http://data.stackexchange.com/metasuperuser/query/10950/progress-towards-editor-badges
-- Progress towards editor badges
-- Determines how many edits remain before achieving the Editor, Strunk and White and Copy Editor badges
DECLARE theSelect CURSOR FOR
  SELECT
    COUNT(*)
  FROM
    Posts
  WHERE
    (PostTypeId = 1 OR PostTypeId = 2)
    AND LastEditorUserId = @UserId
    AND OwnerUserId != @UserId
OPEN theSelect

DECLARE @TotalEdits int
DECLARE @EditsRemainingUntilEditor int
DECLARE @EditsRemainingUntilStrunkAndWhite int
DECLARE @EditsRemainingUntilCopyEditor int

FETCH NEXT FROM theSelect into @TotalEdits

SET @EditsRemainingUntilEditor = 1 - @TotalEdits
SET @EditsRemainingUntilStrunkAndWhite = 100 - @TotalEdits
SET @EditsRemainingUntilCopyEditor = 600 - @TotalEdits

IF @EditsRemainingUntilEditor < 0
BEGIN
  SET @EditsRemainingUntilEditor = 0
END

IF @EditsRemainingUntilStrunkAndWhite < 0
BEGIN
  SET @EditsRemainingUntilStrunkAndWhite = 0
END

IF @EditsRemainingUntilCopyEditor < 0
BEGIN
  SET @EditsRemainingUntilCopyEditor = 0
END

SELECT @EditsRemainingUntilEditor AS 'Edits needed to earn Editor badge', @EditsRemainingUntilStrunkAndWhite  AS 'Edits needed to earn Strunk & White badge', @EditsRemainingUntilCopyEditor  AS 'Edits needed to earn Copy Editor badge'

Enter Parameters

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