Misplaced Pages

User:MZMcBride/Sandbox 5: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:MZMcBride Browse history interactively← Previous editContent deleted Content addedVisualWikitext
Revision as of 03:32, 13 January 2014 editMZMcBride (talk | contribs)Extended confirmed users190,597 edits updated page← Previous edit Latest revision as of 02:51, 3 December 2015 edit undoMZMcBride (talk | contribs)Extended confirmed users190,597 edits updated page 
Line 1: Line 1:
<syntaxhighlight lang="sql">
mzmcbride@willow:~$ cat scripts/misc/articlecount.py
select distinct page_title from page join categorylinks on cl_from = page_id where cl_to = 'Wikipedia_bureaucrats' and page_namespace in (2,3) and substring_index(replace(page_title, '_', ' '), '/', 1) not in (select user_name from user join user_groups on ug_user = user_id where ug_group = 'bureaucrat');
<syntaxhighlight lang="python" enclose="div">
</syntaxhighlight>
#! /usr/bin/env python


<syntaxhighlight lang="sql">
# Copyright 2010 bjweeks, MZMcBride
select distinct page_title from page join categorylinks on cl_from = page_id where cl_to = 'Wikipedia_administrators' and page_namespace in (2,3) and substring_index(replace(page_title, '_', ' '), '/', 1) not in (select user_name from user join user_groups on ug_user = user_id where ug_group = 'sysop');
</syntaxhighlight>


# ]
# 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 = 'Misplaced Pages:List of Wikipedians by article count/Data'
# ]

# ]
report_template = u'''\
# ]
{| class="wikitable sortable"
# ]
|- style="white-space:nowrap;"
# ]
! No.
# ]
! User
# ]
! Article count
# ]
|-
# ]
%s
# ]
|}
# ]
'''
# ]

# ]
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;
# ]
''')
# ]

# ]
def thous(x): # From http://code.activestate.com/recipes/498181/
# ]
return re.sub(r'(\d{3})(?=\d)', r'\1,', str(x))
# ]

# ]
i = 1
# ]
output =
# ]
for row in cursor.fetchall():
# ]
page_creator = u'%s' % unicode(row, 'utf-8')
# ]
article_count = thous(str(row))
# ]
table_row = u'''| %d
# ]
| %s
# ]
| %s
# ]
|-''' % (i, page_creator, article_count)
# ]
output.append(table_row)
# ]
i += 1
# ]

# ]
report = wikitools.Page(wiki, report_title)
# ]
report_text = report_template % ('\n'.join(output))
# ]
report_text = report_text.encode('utf-8')
# ]
report.edit(report_text, summary=settings.editsumm, bot=1)
# ]

# ]
cursor.close()
# ]
conn.close()
# ]
</syntaxhighlight>
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]
# ]

Latest revision as of 02:51, 3 December 2015

select distinct page_title from page join categorylinks on cl_from = page_id where cl_to = 'Wikipedia_bureaucrats' and page_namespace in (2,3) and substring_index(replace(page_title, '_', ' '), '/', 1) not in (select user_name from user join user_groups on ug_user = user_id where ug_group = 'bureaucrat');

select distinct page_title from page join categorylinks on cl_from = page_id where cl_to = 'Wikipedia_administrators' and page_namespace in (2,3) and substring_index(replace(page_title, '_', ' '), '/', 1) not in (select user_name from user join user_groups on ug_user = user_id where ug_group = 'sysop');
  1. User:Daveydweeb
  2. User:Slumgum
  3. User:Tra
  4. User:Amalas
  5. User:LAX
  6. User:Melesse
  7. User:UberScienceNerd
  8. User:Vaoverland/Administrator_role
  9. User:Stephen_Bain
  10. User:Vaoverland/aboutme
  11. User:Le_Faux_Nez_de_L'Aquatique
  12. User:L'Aquatique
  13. User:Hmwith
  14. User:Fainites
  15. User:Magister_Mathematicae
  16. User:EyeSerene
  17. User:Climie.ca
  18. User:JWSchmidt
  19. User:Jtdirl
  20. User:Davidgothberg
  21. User:Sam_Vimes
  22. User:Tkinias
  23. User:CJLL_Wright
  24. User:Jj137
  25. User:Hu12
  26. User:Hamster_Sandwich
  27. User:RyanGerbil10
  28. User:DO11.10
  29. User:Mtmelendez
  30. User:Bryan_Derksen
  31. User:David_Newton
  32. User:Pablo-flores
  33. User:FisherQueen
  34. User:Mysekurity
  35. User:Kakofonous
  36. User:Danger
  37. User:Henrik
  38. User:Jredmond
  39. User:Qaz
  40. User:Ronline
  41. User:Dsmdgold
  42. User:Shanel
  43. User:Hit_bull,_win_steak
  44. User:BirgitteSB
  45. User:Seb26
  46. User:Kilo-Lima
  47. User:Leebo
  48. User:Diberri
  49. User:Kbthompson
  50. User:Stevenfruitsmaak
  51. User:Canderson7
  52. User:Qwghlm
  53. User:ClockworkSoul
  54. User:Wifione/userboxes
  55. User:Wifione/userbox1
  56. User:Shell_Kinney/Infobox
  57. User:Dieter_Simon
  58. User:Wagino_20100516
  59. User:Tlranln999
  60. User:Paxse
  61. User:Jimsjohnson
  62. User:Hrengifo
  63. User:Kristtty
  64. User:Arjun01
  65. User:Nad808080
  66. User:Kristoffer_L
  67. User:Joseph_the_writer
  68. User:PatSunter
  69. User:VancityEditor
  70. User:Ramon_Serra
  71. User:MikeLynch
  72. User:Alliver
  73. User:Tcvella
  74. User:SausageParty77934
  75. User:TranslatorUK
  76. User:Junirullah/sandbox
  77. User:Prof.junirullah/sandbox
  78. User:Dry_Martini
  79. User:Oskar_Sigvardsson/List_of_administrators
  80. User:Jamlaw223
  81. User:Max7310
  82. User:Sonulangaya
  83. User:Reigndeleon
  84. User:Elen_of_the_Roads
  85. User:Pat.moloney
  86. User:Rocking_ramlal
  87. User:Vivekprakash92
  88. User:Gmaxwell/adminship_map
  89. User:Stewartadcock
  90. User:Kaiger
  91. User:TheElderFox
  92. User:Ronald7488
  93. User:Sivaraam07
  94. User:RaysRates
  95. User:Xbowery
  96. User:ChriCom
  97. User:Tropicalpurplekitty
  98. User:Sobek121
  99. User:Mel_Etitis/sandbox
  100. User:Loreanar
  101. User:Phiraphon
  102. User:Jiale8331
  103. User:Hyipworld
  104. User:Betsy6286
  105. User:Admiral_Alvin
  106. User:ERcheck
  107. User:Billyoweston
  108. User:Bagumbe