浏览代码

Make query even more efficient.

pull/15/head
Ben Kurtovic 11 年前
父节点
当前提交
04eecede21
共有 1 个文件被更改,包括 14 次插入14 次删除
  1. +14
    -14
      tasks/afc_statistics.py

+ 14
- 14
tasks/afc_statistics.py 查看文件

@@ -232,26 +232,26 @@ class AFCStatistics(Task):
query = """SELECT s.page_id, s.page_title, s.page_modify_oldid,
r.page_latest, r.page_title, r.page_namespace
FROM page AS s
LEFT JOIN {0}_p.page AS r ON s.page_id = r.page_id"""
LEFT JOIN {0}_p.page AS r ON s.page_id = r.page_id
WHERE s.page_modify_oldid != r.page_latest"""
cursor.execute(query.format(self.site.name))

for pageid, title, oldid, real_oldid, real_title, real_ns in cursor:
if not real_oldid:
self.untrack_page(cursor, pageid)
continue
if oldid != real_oldid:
msg = u"Updating page [[{0}]] (id: {1}) @ {2}"
self.logger.debug(msg.format(title, pageid, oldid))
self.logger.debug(" {0} -> {1}".format(oldid, real_oldid))
real_title = real_title.decode("utf8").replace("_", " ")
ns = self.site.namespace_id_to_name(real_ns)
if ns:
real_title = u":".join((ns, real_title))
try:
self.update_page(cursor, pageid, real_title)
except Exception:
e = u"Error updating page [[{0}]] (id: {1})"
self.logger.exception(e.format(real_title, pageid))
msg = u"Updating page [[{0}]] (id: {1}) @ {2}"
self.logger.debug(msg.format(title, pageid, oldid))
self.logger.debug(" {0} -> {1}".format(oldid, real_oldid))
real_title = real_title.decode("utf8").replace("_", " ")
ns = self.site.namespace_id_to_name(real_ns)
if ns:
real_title = u":".join((ns, real_title))
try:
self.update_page(cursor, pageid, real_title)
except Exception:
e = u"Error updating page [[{0}]] (id: {1})"
self.logger.exception(e.format(real_title, pageid))

def add_untracked(self, cursor):
"""Add pending submissions that are not yet tracked.


正在加载...
取消
保存