Explorar el Código

Store page size as an int of bytes, not a string.

pull/15/head
Ben Kurtovic hace 11 años
padre
commit
243078a81a
Se han modificado 2 ficheros con 5 adiciones y 11 borrados
  1. +4
    -10
      tasks/afc_statistics.py
  2. +1
    -1
      tasks/schema/afc_statistics.sql

+ 4
- 10
tasks/afc_statistics.py Ver fichero

@@ -349,7 +349,6 @@ class AFCStatistics(Task):
self.logger.warn(msg)
return

size = self.get_size(content)
m_user, m_time, m_id = self.get_modify(pageid)
s_user, s_time, s_id = self.get_special(pageid, chart)
notes = self.get_notes(chart, content, m_time, s_user)
@@ -357,8 +356,8 @@ class AFCStatistics(Task):
query1 = "INSERT INTO row VALUES (?, ?)"
query2 = "INSERT INTO page VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
cursor.execute(query1, (pageid, chart))
cursor.execute(query2, (pageid, status, title, size, notes, m_user,
m_time, m_id, s_user, s_time, s_id))
cursor.execute(query2, (pageid, status, title, len(content), notes,
m_user, m_time, m_id, s_user, s_time, s_id))

def update_page(self, cursor, pageid, title):
"""Update hook for when page is already in our database.
@@ -384,15 +383,14 @@ class AFCStatistics(Task):
dict_cursor.execute(query, (pageid,))
result = dict_cursor.fetchall()[0]

size = self.get_size(content)
m_user, m_time, m_id = self.get_modify(pageid)

if title != result["page_title"]:
self.update_page_title(cursor, result, pageid, title)

if m_id != result["page_modify_oldid"]:
self.update_page_modify(cursor, result, pageid, size, m_user,
m_time, m_id)
self.update_page_modify(cursor, result, pageid, len(content),
m_user, m_time, m_id)

if status != result["page_status"]:
special = self.update_page_status(cursor, result, pageid, status,
@@ -549,10 +547,6 @@ class AFCStatistics(Task):
statuses.append(aliases[name])
return statuses

def get_size(self, content):
"""Return a page's size in a short, pretty format."""
return "{0} kB".format(round(len(content) / 1000.0, 1))

def get_modify(self, pageid):
"""Return information about a page's last edit ("modification").



+ 1
- 1
tasks/schema/afc_statistics.sql Ver fichero

@@ -53,7 +53,7 @@ CREATE TABLE `page` (
`page_id` int(10) unsigned NOT NULL,
`page_status` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL,
`page_title` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
`page_size` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL,
`page_size` int(6) unsigned NOT NULL,
`page_notes` tinytext COLLATE utf8_unicode_ci,
`page_modify_user` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`page_modify_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',


Cargando…
Cancelar
Guardar