From ed2a686f5d5c591c2775338397ad85f8df17279c Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Tue, 28 Jul 2015 17:45:40 -0700 Subject: [PATCH] Script refinement Add an implicit "anonymous" poster with the OID e4edb497-3f6f-4a7e-8ad4-0272ab8d3a47. This OID is not normally valid and is a type-4 UUID generated from uuidgen(1). --- db/.gitignore | 1 + db/db.sql | 6 ++++++ scripts/getuserinfo.moon | 4 +++- scripts/scrape.moon | 3 +++ 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 db/.gitignore diff --git a/db/.gitignore b/db/.gitignore new file mode 100644 index 0000000..6d31f69 --- /dev/null +++ b/db/.gitignore @@ -0,0 +1 @@ +db.back.sql diff --git a/db/db.sql b/db/db.sql index 717b9cb..e6cc0f4 100644 --- a/db/db.sql +++ b/db/db.sql @@ -13,3 +13,9 @@ CREATE TABLE IF NOT EXISTS Users ( , name TEXT UNIQUE NOT NULL , avatar_url TEXT NOT NULL ); + +BEGIN TRANSACTION; + +INSERT INTO Users VALUES(NULL, "e4edb497-3f6f-4a7e-8ad4-0272ab8d3a47", "Background Pony", '//derpicdn.net/assets/no_avatar_125x125-2c4e2d8e68cb13a208dae3c6d6877b45c5390dd367920d927c80dde1665bc0ed.png'); + +COMMIT; diff --git a/scripts/getuserinfo.moon b/scripts/getuserinfo.moon index 887e864..1a76312 100644 --- a/scripts/getuserinfo.moon +++ b/scripts/getuserinfo.moon @@ -3,7 +3,9 @@ json = require "dkjson" socket = require "socket" sqlite3 = require "lsqlite3" -authors = {} +authors = { + ["e4edb497-3f6f-4a7e-8ad4-0272ab8d3a47"]: true +} db = assert sqlite3.open "../db/posts.db" diff --git a/scripts/scrape.moon b/scripts/scrape.moon index 1ea4257..f9311c1 100644 --- a/scripts/scrape.moon +++ b/scripts/scrape.moon @@ -17,6 +17,9 @@ for page=1,8002 for _, post in pairs posts.topics continue unless post + + post.author = "e4edb497-3f6f-4a7e-8ad4-0272ab8d3a47" unless post.author + do insert_stmt\bind_values post.id, post.body, post.author, page insert_stmt\step!