# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>;.
import datetime
import MySQLdb
import re
import wikitools
import settings
report_title = 'Wikipedia:List of Wikipedians by article count/Data'
wiki = wikitools.Wiki()
wiki.login(settings.username, settings.password)
conn = MySQLdb.connect(host=settings.host, db=settings.dbname, read_default_file='~/.my.cnf')
cursor = conn.cursor()
cursor.execute('''
/* articlecount.py SLOW_OK */
SELECT
p2.page_creator,
COUNT(*)
FROM enwiki_p.page AS p1
JOIN u_mzmcbride_enwiki_page_creators_p.page AS p2
ON p1.page_id = p2.page_id
AND p1.page_namespace = 0
AND p1.page_is_redirect = 0
GROUP BY p2.page_creator
ORDER BY COUNT(*) DESC
LIMIT 3000;
''')