diff options
author | Blake DeMarcy <ofunknowndescent@gmail.com> | 2017-04-02 23:23:19 -0500 |
---|---|---|
committer | Blake DeMarcy <ofunknowndescent@gmail.com> | 2017-04-02 23:23:19 -0500 |
commit | af5b53e7e34839f53e702209e0c4c23c23010d22 (patch) | |
tree | ab89434ae864a73d72ab15ddb1d18c1166cadeac /src | |
parent | 73a9063f93c572ce388c7d84fab56a64cc0ac107 (diff) | |
download | bbj-af5b53e7e34839f53e702209e0c4c23c23010d22.tar.gz |
refine message object schema; update docstrings
Diffstat (limited to 'src')
-rw-r--r-- | src/db.py | 14 |
1 files changed, 3 insertions, 11 deletions
@@ -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 |