From f448173b189c9e0f9ccac487ce2e25d29abd3610 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Mon, 30 Jan 2012 10:40:02 +0100 Subject: [PATCH] Bring back the groupid in list-of-lists for search Seems we were actually using this :-) --- tools/search/crawler/listsync.py | 10 +++++++--- tools/search/sql/schema.sql | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/search/crawler/listsync.py b/tools/search/crawler/listsync.py index 09f9e205..cd22be3d 100755 --- a/tools/search/crawler/listsync.py +++ b/tools/search/crawler/listsync.py @@ -19,9 +19,9 @@ if __name__=="__main__": u.close() # We don't care about the groups here, just the lists! - curs.execute("SELECT id, name, active FROM lists") + curs.execute("SELECT id, name, groupid, active FROM lists") lists = curs.fetchall() - for id, name, active in lists: + for id, name, groupid, active in lists: thislist = [x for x in obj['lists'] if x['id'] == id] if len(thislist) == 0: log("List %s should be removed, do that manually!" % name) @@ -35,11 +35,15 @@ if __name__=="__main__": if thislist[0]['active'] != active: log("Changing active flag for %s to %s" % (l['name'], l['active'])) curs.execute("UPDATE lists SET active=%(active)s WHERE id=%(id)s", l) + if thislist[0]['groupid'] != groupid: + log("Changing group for %s to %s" % (l['name'], l['groupid'])) + curs.execute("UPDATE lists SET groupid=%(groupid)s WHERE id=%(id)s", l) + for l in obj['lists']: thislist = [x for x in lists if x[0] == l['id']] if len(thislist) == 0: log("Adding list %s" % l['name']) - curs.execute("INSERT INTO lists (id, name, active, pagecount) VALUES (%(id)s, %(name)s, %(active)s, 0)", + curs.execute("INSERT INTO lists (id, name, groupid, active, pagecount) VALUES (%(id)s, %(name)s, %(groupid)s, %(active)s, 0)", l) conn.commit() diff --git a/tools/search/sql/schema.sql b/tools/search/sql/schema.sql index 0a699f71..83573259 100644 --- a/tools/search/sql/schema.sql +++ b/tools/search/sql/schema.sql @@ -2,6 +2,7 @@ CREATE TABLE lists ( id int NOT NULL PRIMARY KEY, name varchar(64) NOT NULL, active bool NOT NULL, + grp int NOT NULL, pagecount int NOT NULL ); -- 2.39.5