Bläddra i källkod

Make query even more efficient.

pull/15/head
Ben Kurtovic 11 år sedan
förälder
incheckning
04eecede21
1 ändrade filer med 14 tillägg och 14 borttagningar
  1. +14
    -14
      tasks/afc_statistics.py

+ 14
- 14
tasks/afc_statistics.py Visa fil

@@ -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.


Laddar…
Avbryt
Spara