Fork of Teahouse preinvite activites (v3) by EpochFail
This query is marked as a draft This query has been published by Dchen (WMF).

SQL

AخA
 
SELECT                                                                                                                             
  user_id,                                                                                                                         
  COUNT(rev_id) AS edits,                                                                                                          
  SUM(page_namespace = 0) AS main_edits,                                                                                           
  SUM(page_namespace = 1) AS talk_edits,                                                                                           
  SUM(page_namespace = 2) AS user_edits,                                                                                           
  SUM(page_namespace = 3) AS user_talk_edits,                                                                                      
  SUM(page_namespace IN (4,5)) AS wp_edits,                                                                                        
  SUM(page_namespace > 5) AS other_edits                                                                                           
FROM (                                                                                                                             
    (SELECT                                                                                                                        
        user_id,
        rev_id,
        page_namespace                                                                                               
    FROM u2041__thr_p.th3_experimental_user
    INNER JOIN enwiki_p.user USING (user_id)
    LEFT JOIN enwiki_p.revision_userindex ON                                                                                                          
        rev_user = user_id AND                                                                                                     
        rev_timestamp between DATE_FORMAT(user_registration,"%Y%m%d%H%i%S")
        and DATE_FORMAT(invite_date,"%Y%m%d%H%i%S")
     
    LEFT JOIN enwiki_p.page ON rev_page = page_id)
    UNION                                                                                                                          
    (SELECT                                                                                                                        
        user_id,
        ar_rev_id AS rev_id,
        ar_namespace AS page_namespace                                                                                               
    FROM u2041__thr_p.th3_experimental_user
    INNER JOIN enwiki_p.user USING (user_id)
    LEFT JOIN enwiki_p.archive_userindex ON                                                                                                          
        ar_user = user_id AND                                                                                                     
        ar_timestamp between DATE_FORMAT(user_registration,"%Y%m%d%H%i%S")
        and DATE_FORMAT(invite_date,"%Y%m%d%H%i%S")
   )
) AS foo
GROUP BY user_id;
By running queries you agree to the Cloud Services Terms of Use and you irrevocably agree to release your SQL under CC0 License.
All SQL code is licensed under CC0 License.

Checking query status...