Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit ea911c5

Browse files
committed
Fix bug in clear_all
1 parent c004956 commit ea911c5

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

db/datastore.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -853,22 +853,14 @@ def delete_moderator(self, guid):
853853
conn.close()
854854

855855
def clear_all(self, except_guids=None):
856-
mods = []
857-
if except_guids is not None:
858-
for guid in except_guids:
859-
info = self.get_moderator(guid)
860-
mods.append(info)
856+
if except_guids is None:
857+
except_guids = []
861858
conn = Database.connect_database(self.PATH)
862859
with conn:
863860
cursor = conn.cursor()
864-
cursor.execute('''DELETE FROM moderators''')
861+
cursor.execute('''DELETE FROM moderators WHERE guid NOT IN ({seq})'''.format(
862+
seq=','.join(['?']*len(except_guids))), except_guids)
865863
conn.commit()
866-
for mod in mods:
867-
if mod is not None:
868-
cursor.execute('''INSERT OR REPLACE INTO moderators(guid, pubkey, bitcoinKey,
869-
bitcoinSignature, handle, name, description, avatar, fee)
870-
VALUES (?,?,?,?,?,?,?,?,?)''', (mod[0], mod[1], mod[2], mod[3], mod[4],
871-
mod[5], mod[6], mod[7], mod[8]))
872864

873865
conn.close()
874866

0 commit comments

Comments
 (0)