浏览代码

Fix update_date() when a submission is in multiple date categories.

tags/v0.1^2
Ben Kurtovic 13 年前
父节点
当前提交
ed8751970f
共有 1 个文件被更改,包括 12 次插入13 次删除
  1. +12
    -13
      bot/tasks/afc_history.py

+ 12
- 13
bot/tasks/afc_history.py 查看文件

@@ -93,29 +93,28 @@ class Task(BaseTask):
msg = "Updating {0} ([[{1}]])".format(date, category.title())
self.logger.debug(msg)

q_select = "SELECT page_id, page_status FROM page WHERE page_date = ?"
q_select = "SELECT page_date, page_status FROM page WHERE page_id = ?"
q_delete = "DELETE FROM page WHERE page_id = ?"
q_update = "UPDATE page SET page_status = ? WHERE page_id = ?"
q_update = "UPDATE page SET page_date = ?, page_status = ? WHERE page_id = ?"
q_insert = "INSERT INTO page VALUES (?, ?, ?)"
members = category.members(use_sql=True)
tracked = []
statuses = {}

with self.conn.cursor() as cursor:
cursor.execute(q_select, (date,))
for pageid, status in cursor:
tracked.append(pageid)
statuses[pageid] = status

for title, pageid in members:
cursor.execute(q_select, (pageid,))
stored = cursor.fetchall()
status = self.get_status(title, pageid)

if status == STATUS_NONE:
if pageid in tracked:
if stored:
cursor.execute(q_delete, (pageid,))
continue
if pageid in tracked:
if status != statuses[pageid]:
cursor.execute(q_update, (status, pageid))

if stored:
stored_date, stored_status = list(stored)
if date != stored_date or status != stored_status:
cursor.execute(q_update, (date, status, pageid))

else:
cursor.execute(q_insert, (pageid, date, status))



正在加载...
取消
保存