aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBlake DeMarcy <ofunknowndescent@gmail.com>2017-04-02 23:23:19 -0500
committerBlake DeMarcy <ofunknowndescent@gmail.com>2017-04-02 23:23:19 -0500
commitaf5b53e7e34839f53e702209e0c4c23c23010d22 (patch)
treeab89434ae864a73d72ab15ddb1d18c1166cadeac /src
parent73a9063f93c572ce388c7d84fab56a64cc0ac107 (diff)
downloadbbj-af5b53e7e34839f53e702209e0c4c23c23010d22.tar.gz
refine message object schema; update docstrings
Diffstat (limited to 'src')
-rw-r--r--src/db.py14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/db.py b/src/db.py
index 76c900c..a3c9155 100644
--- a/src/db.py
+++ b/src/db.py
@@ -36,13 +36,6 @@ def thread_get(connection, thread_id, messages=True):
MESSAGES, if False, will omit the inclusion of a thread's messages
and only get its metadata, such as title, author, etc.
-
- FORMATTER should be a callable object who takes a body string
- as it's only argument and returns an object to be sent in the
- response. It isn't strictly necessary that it returns a string,
- for example the entity parser will return an array with the
- body string and another array with indices and types of objects
- contained in it.
"""
c = connection.cursor()
c.execute("SELECT * FROM threads WHERE thread_id = ?", (thread_id,))
@@ -53,12 +46,11 @@ def thread_get(connection, thread_id, messages=True):
thread = schema.thread(*thread)
if messages:
- c.execute("SELECT * FROM messages WHERE thread_id = ?", (thread_id,))
+ c.execute("""SELECT * FROM messages WHERE thread_id = ?
+ ORDER BY post_id""", (thread_id,))
# create a dictionary where each message is accessible by its
# integer post_id as a key
- thread["messages"] = \
- {message["post_id"]: message for message in
- [schema.message(*values) for values in c.fetchall()]}
+ thread["messages"] = [schema.message(*values) for values in c.fetchall()]
return thread
Un proyecto texto-plano.xyz