أرابيكا:تقارير قاعدة البيانات/PRODed articles with deletion logs/Configuration

من أرابيكا، الموسوعة الحرة
اذهب إلى التنقل اذهب إلى البحث
#!/usr/bin/env python
# encoding: utf-8
"""
PreviouslyDeletedProds.py


Copyright (c) Tim Sears. All rights reserved.
"""
##Config
from CONFIG import *
from urllib import quote
report_title='Wikipedia:Database_reports/PRODed_articles_with_deletion_logs'
report_template = u'''
List of [[أرابيكا:PROD|PRODed]] articles that have previously been deleted. Limited to the first 500 articles. Data as of <onlyinclude>~~~~~</onlyinclude>.




{| class="wikitable sortable plainlinks"
|-
! Article
! Number of entries in deletion log
! First deletion
! Latest deletion
|-
%s
|}
<small>(Took %.2f seconds to generate)</small>
'''
###
def toTS(d):
	d=str(d)
	return d[:4]+'-'+d[4:6]+'-'+d[6:8]+' '+d[8:10]+':'+d[10:12]+':'+d[12:14]
query='''SELECT /* SLOW_OK */ page_title, count(log_timestamp),min(log_timestamp), max(log_timestamp) from page
join categorylinks on cl_from=page_id and cl_to="All_articles_proposed_for_deletion"
JOIN logging_ts_alternative on log_title=page_title and log_namespace=0 and log_type='delete' and log_action='delete'
where page_namespace=0
group by page_title
limit 500;'''
site=wikipedia.getSite()
db = connect(host=HOSTNAME, db=DATABSENAME, read_default_file='~/.my.cnf')
t=time()
print '* Running query "Previously Deleted Prods"...'
cursor=db.cursor()
cursor.execute(query)


t=time()-t
print ':Done! Took',t,'seconds.'
print '* Generating result table.'


row=''
for article,numdeletions,firstdeletion,lastdeletion in cursor.fetchall():
        row+="""\n|[[:%s]]
        |[{{fullurl:Special:Log|type=delete&page=%s}} %d]
        |[{{fullurl:Special:Log|dir=prev&offset=%s&type=delete&page=%s&limit=1}} %s]
        |[{{fullurl:Special:Log|dir=prev&offset=%s&type=delete&page=%s&limit=1}} %s]
        |-"""%(unicode(article.replace('_',' '),'utf-8'),
 				quote(article),numdeletions,
				int(firstdeletion)-1,quote(article), toTS(firstdeletion),
				int(lastdeletion)-1, quote(article),toTS(lastdeletion))




report_template=report_template%(row,t)
report_page=wikipedia.Page(site,report_title)
report_page.put(report_template,comment='Updating Page...')

Crontab

50 07 * * * python $HOME/PreviouslyDeletedProds.py >/dev/null 2>&1