|
@@ -126,6 +126,8 @@ class DRNClerkBot(Task): |
|
|
if self.shutoff_enabled(): |
|
|
if self.shutoff_enabled(): |
|
|
return |
|
|
return |
|
|
self.update_chart(conn, site) |
|
|
self.update_chart(conn, site) |
|
|
|
|
|
if action in ["all", "purge"]: |
|
|
|
|
|
self.purge_old_data(conn) |
|
|
finally: |
|
|
finally: |
|
|
self.db_access_lock.release() |
|
|
self.db_access_lock.release() |
|
|
|
|
|
|
|
@@ -203,7 +205,8 @@ class DRNClerkBot(Task): |
|
|
re_id2 += r"(.*?)\}\})(<!-- Bot Case ID \(please don't modify\): .*? -->)?" |
|
|
re_id2 += r"(.*?)\}\})(<!-- Bot Case ID \(please don't modify\): .*? -->)?" |
|
|
repl = ur"\1 <!-- Bot Case ID (please don't modify): {0} -->" |
|
|
repl = ur"\1 <!-- Bot Case ID (please don't modify): {0} -->" |
|
|
body = re.sub(re_id2, repl.format(id_), body) |
|
|
body = re.sub(re_id2, repl.format(id_), body) |
|
|
re_f = r"\{\{drn filing editor\|(.*?)\|(\d{2}:\d{2},\s\d{1,2}\s\w+\s\d{4}\s\(UTC\))\}\}" |
|
|
|
|
|
|
|
|
re_f = r"\{\{drn filing editor\|(.*?)\|" |
|
|
|
|
|
re_f += r"(\d{2}:\d{2},\s\d{1,2}\s\w+\s\d{4}\s\(UTC\))\}\}" |
|
|
match = re.search(re_f, body, re.U) |
|
|
match = re.search(re_f, body, re.U) |
|
|
if match: |
|
|
if match: |
|
|
f_user = match.group(1).split("/", 1)[0].replace("_", " ") |
|
|
f_user = match.group(1).split("/", 1)[0].replace("_", " ") |
|
@@ -246,7 +249,7 @@ class DRNClerkBot(Task): |
|
|
for option, names in self.ALIASES.iteritems(): |
|
|
for option, names in self.ALIASES.iteritems(): |
|
|
if status.group(1).lower() in names: |
|
|
if status.group(1).lower() in names: |
|
|
return option |
|
|
return option |
|
|
return self.STATUS_UNKNOWN |
|
|
|
|
|
|
|
|
return self.STATUS_NEW |
|
|
|
|
|
|
|
|
def update_case_title(self, conn, id_, title): |
|
|
def update_case_title(self, conn, id_, title): |
|
|
"""Update a case title in the database.""" |
|
|
"""Update a case title in the database.""" |
|
@@ -262,7 +265,9 @@ class DRNClerkBot(Task): |
|
|
volunteers = [name for (name,) in cursor.fetchall()] |
|
|
volunteers = [name for (name,) in cursor.fetchall()] |
|
|
notices = [] |
|
|
notices = [] |
|
|
for case in cases: |
|
|
for case in cases: |
|
|
if case.status != self.STATUS_UNKNOWN: |
|
|
|
|
|
|
|
|
if case.status == self.STATUS_UNKNOWN: |
|
|
|
|
|
self.clerk_unknown_case(conn, case) |
|
|
|
|
|
else: |
|
|
notices += self.clerk_case(conn, case, volunteers) |
|
|
notices += self.clerk_case(conn, case, volunteers) |
|
|
return notices |
|
|
return notices |
|
|
|
|
|
|
|
@@ -358,6 +363,12 @@ class DRNClerkBot(Task): |
|
|
case.body += "\n{{" + arch_bottom + "}}" |
|
|
case.body += "\n{{" + arch_bottom + "}}" |
|
|
case.status = self.STATUS_UNKNOWN |
|
|
case.status = self.STATUS_UNKNOWN |
|
|
|
|
|
|
|
|
|
|
|
def clerk_unknown_case(self, conn, case): |
|
|
|
|
|
if case.new: |
|
|
|
|
|
self.save_new_case(conn, case) |
|
|
|
|
|
else: |
|
|
|
|
|
self.save_existing_case(conn, case) |
|
|
|
|
|
|
|
|
def check_for_review(self, case): |
|
|
def check_for_review(self, case): |
|
|
age = (datetime.utcnow() - case.file_time).total_seconds() |
|
|
age = (datetime.utcnow() - case.file_time).total_seconds() |
|
|
if age > 60 * 60 * 24 * 4: |
|
|
if age > 60 * 60 * 24 * 4: |
|
@@ -606,6 +617,16 @@ class DRNClerkBot(Task): |
|
|
msg.append(chunk) |
|
|
msg.append(chunk) |
|
|
return ", ".join(msg) + " ago" if msg else "0 hours ago" |
|
|
return ", ".join(msg) + " ago" if msg else "0 hours ago" |
|
|
|
|
|
|
|
|
|
|
|
def purge_old_data(self, conn): |
|
|
|
|
|
query = """DELETE cases, signatures |
|
|
|
|
|
FROM cases JOIN signatures ON case_id = signature_case |
|
|
|
|
|
WHERE case_status = ? |
|
|
|
|
|
AND case_file_time < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 30 DAY) |
|
|
|
|
|
AND case_modify_time < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 30 DAY) |
|
|
|
|
|
""" |
|
|
|
|
|
with conn.cursor() as cursor: |
|
|
|
|
|
cursor.execute(query, (self.STATUS_UNKNOWN,)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _Case(object): |
|
|
class _Case(object): |
|
|
"""A object representing a dispute resolution case.""" |
|
|
"""A object representing a dispute resolution case.""" |
|
|