diff options
author | Blake DeMarcy <ofunknowndescent@gmail.com> | 2017-04-25 03:36:51 -0500 |
---|---|---|
committer | Blake DeMarcy <ofunknowndescent@gmail.com> | 2017-04-25 03:36:51 -0500 |
commit | 0f6846c3609c3b8caa34a296355e06d18261a1e1 (patch) | |
tree | 4fc46a36625b844f3c65ddd7b6062ea01b23efe0 /src | |
parent | 90b5573f842e1be81743194705fa94c41969da61 (diff) | |
download | bbj-0f6846c3609c3b8caa34a296355e06d18261a1e1.tar.gz |
add new parameter to threads: last_author
Diffstat (limited to 'src')
-rw-r--r-- | src/db.py | 8 | ||||
-rw-r--r-- | src/schema.py | 6 | ||||
-rw-r--r-- | src/utils.py | 3 |
3 files changed, 11 insertions, 6 deletions
@@ -106,11 +106,12 @@ def thread_create(connection, author_id, body, title, send_raw=False): thread_id = uuid1().hex scheme = schema.thread( thread_id, author_id, title, - now, now, -1, False) # see below for why i set -1 instead of 0 + now, now, -1, # see below for why i set -1 instead of 0 + False, author_id) connection.execute(""" INSERT INTO threads - VALUES (?,?,?,?,?,?,?) + VALUES (?,?,?,?,?,?,?,?) """, schema_values("thread", scheme)) connection.commit() # the thread is initially commited with reply_count -1 so that i can @@ -147,9 +148,10 @@ def thread_reply(connection, author_id, thread_id, body, send_raw=False, time_ov connection.execute(""" UPDATE threads SET reply_count = ?, + last_author = ?, last_mod = ? WHERE thread_id = ? - """, (count, now, thread_id)) + """, (count, author_id, now, thread_id)) connection.commit() return scheme diff --git a/src/schema.py b/src/schema.py index 7044c37..aedb765 100644 --- a/src/schema.py +++ b/src/schema.py @@ -128,7 +128,8 @@ def thread( last_mod, # floating point unix timestamp (of last post or post edit) created, # floating point unix timestamp (when thread was made) reply_count, # integer (incremental, starting with 0) - pinned): # boolean + pinned, # boolean + last_author): # uuid string return { "thread_id": thread_id, @@ -137,7 +138,8 @@ def thread( "last_mod": last_mod, "created": created, "reply_count": reply_count, - "pinned": bool(pinned) + "pinned": bool(pinned), + "last_author": last_author } diff --git a/src/utils.py b/src/utils.py index c533112..dbe4789 100644 --- a/src/utils.py +++ b/src/utils.py @@ -22,7 +22,8 @@ def schema_values(scheme, obj): elif scheme == "thread": return ordered_keys(obj, "thread_id", "author", "title", - "last_mod", "created", "reply_count", "pinned") + "last_mod", "created", "reply_count", + "pinned", "last_author") elif scheme == "message": return ordered_keys(obj, |