From ef4c7a187a6eaec150e7c9f4ab73e0fa812df3a3 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sat, 28 Jul 2012 01:14:42 -0400 Subject: [PATCH] update_case_title() --- earwigbot/tasks/drn_clerkbot.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/earwigbot/tasks/drn_clerkbot.py b/earwigbot/tasks/drn_clerkbot.py index ae457e1..954aa6a 100644 --- a/earwigbot/tasks/drn_clerkbot.py +++ b/earwigbot/tasks/drn_clerkbot.py @@ -176,6 +176,10 @@ class DRNClerkBot(Task): body = re.sub(re_id2, repl.format(id_), body) case = _Case(id_, title, status) cases.append(case) + else: + if case.title != title: + self.update_case_title(conn, id_, title) + case.title = title case.body, case.old = body, old def select_next_id(self, conn): @@ -208,6 +212,12 @@ class DRNClerkBot(Task): return option return self.STATUS_UNKNOWN + def update_case_title(self, conn, id_, title): + """Update a case title in the database.""" + query = "UPDATE case SET case_title = ? WHERE case_id = ?" + with conn.cursor() as cursor: + cursor.execute(query, (title, id_)) + def clerk(self): """Actually go through cases and modify those to be updated.""" notices = []