Parcourir la source

Rename all tables to plural forms, and fix another bug.

tags/v0.1^2
Ben Kurtovic il y a 12 ans
Parent
révision
1687857c61
2 fichiers modifiés avec 13 ajouts et 13 suppressions
  1. +9
    -9
      earwigbot/tasks/drn_clerkbot.py
  2. +4
    -4
      earwigbot/tasks/schema/drn_clerkbot.sql

+ 9
- 9
earwigbot/tasks/drn_clerkbot.py Voir le fichier

@@ -144,9 +144,9 @@ class DRNClerkBot(Task):
additions.add((user.group(1),))

removals = set()
query1 = "SELECT volunteer_username FROM volunteer"
query2 = "DELETE FROM volunteer WHERE volunteer_username = ?"
query3 = "INSERT INTO volunteer (volunteer_username) VALUES (?)"
query1 = "SELECT volunteer_username FROM volunteers"
query2 = "DELETE FROM volunteers WHERE volunteer_username = ?"
query3 = "INSERT INTO volunteers (volunteer_username) VALUES (?)"
with conn.cursor() as cursor:
cursor.execute(query1)
for row in cursor:
@@ -242,7 +242,7 @@ class DRNClerkBot(Task):

def clerk(self, conn, cases):
"""Actually go through cases and modify those to be updated."""
query = "SELECT volunteer_username FROM volunteer"
query = "SELECT volunteer_username FROM volunteers"
with conn.cursor() as cursor:
cursor.execute(query)
volunteers = [name for (name,) in cursor.fetchall()]
@@ -271,7 +271,7 @@ class DRNClerkBot(Task):
elif case.status == self.STATUS_REVIEW:
notices = self.clerk_review_case(case)
elif case.status in [self.STATUS_RESOLVED, self.STATUS_CLOSED]:
self.clerk_closed_case(conn, signatures)
self.clerk_closed_case(case, signatures)
elif case.status == self.STATUS_UNKNOWN:
pass
else:
@@ -359,7 +359,7 @@ class DRNClerkBot(Task):
return signatures

def get_signatures_from_db(self, conn, case):
query = "SELECT signature_username, signature_timestamp FROM signature WHERE signature_case = ?"
query = "SELECT signature_username, signature_timestamp FROM signatures WHERE signature_case = ?"
with conn.cursor() as cursor:
cursor.execute(query, (case.id,))
return cursor.fetchall()
@@ -410,15 +410,15 @@ class DRNClerkBot(Task):
self.save_existing_case(conn, case)

with conn.cursor() as cursor:
query1 = "DELETE FROM signature WHERE signature_case = ? AND signature_username = ? AND signature_timestamp = ?"
query2 = "INSERT INTO signature VALUES (?, ?, ?, ?)"
query1 = "DELETE FROM signatures WHERE signature_case = ? AND signature_username = ? AND signature_timestamp = ?"
query2 = "INSERT INTO signatures VALUES (?, ?, ?, ?)"
removals = set(storedsigs) - set(sigs)
additions = set(sigs) - set(storedsigs)
if removals:
args = [(case.id, name, stamp) for (name, stamp) in removals]
cursor.execute(query1, args)
if additions:
nextid = self.select_next_id(conn, "signature_id", "signature")
nextid = self.select_next_id(conn, "signature_id", "signatures")
args = []
for name, stamp in additions:
args.append((nextid, case.id, name, stamp))


+ 4
- 4
earwigbot/tasks/schema/drn_clerkbot.sql Voir le fichier

@@ -35,8 +35,8 @@ CREATE TABLE `cases` (
-- Table structure for table `signature`
--

DROP TABLE IF EXISTS `signature`;
CREATE TABLE `signature` (
DROP TABLE IF EXISTS `signatures`;
CREATE TABLE `signatures` (
`signature_id` int(10) unsigned NOT NULL,
`signature_case` int(10) unsigned NOT NULL,
`signature_username` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
@@ -48,8 +48,8 @@ CREATE TABLE `signature` (
-- Table structure for table `volunteer`
--

DROP TABLE IF EXISTS `volunteer`;
CREATE TABLE `volunteer` (
DROP TABLE IF EXISTS `volunteers`;
CREATE TABLE `volunteers` (
`volunteer_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`volunteer_username` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`volunteer_id`)


Chargement…
Annuler
Enregistrer