Skip to content

Instantly share code, notes, and snippets.

@atopal
Last active December 16, 2015 14:49
Show Gist options
  • Select an option

  • Save atopal/5451547 to your computer and use it in GitHub Desktop.

Select an option

Save atopal/5451547 to your computer and use it in GitHub Desktop.
Top English KB contributors in the last 6 month
SELECT username, count(distinct(document_id)) as reveditnum
FROM
(
SELECT username, document_id
FROM wiki_revision wr
JOIN auth_user au ON wr.creator_id = au.id
JOIN wiki_document wd ON wr.document_id = wd.id
WHERE created > '2012-10-24' and created <= '2013-04-24'
AND wd.locale = 'en-US'
UNION
SELECT username, document_id
FROM wiki_revision wr
JOIN auth_user au ON wr.reviewer_id = au.id
JOIN wiki_document wd ON wr.document_id = wd.id
WHERE is_approved
AND reviewed > '2012-10-24' and reviewed <= '2013-04-24'
AND wd.locale = 'en-US'
) AS tablea
GROUP BY username ORDER BY reveditnum DESC LIMIT 50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment