diff options
author | Michael Vetter <jubalh@iodoru.org> | 2020-04-06 19:44:03 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2020-04-06 19:44:03 +0200 |
commit | fb4f82b82c81a9b05be8709f41602c8711f1cae9 (patch) | |
tree | 36cc6e0c1df1eb0d1930553e5a143ccccf01048e /src/database.c | |
parent | 015c5d83d02c2e9300ac799671fb4a237fe37751 (diff) | |
download | profani-tty-fb4f82b82c81a9b05be8709f41602c8711f1cae9.tar.gz |
db: actually display the last 10 entries in correct order
Diffstat (limited to 'src/database.c')
-rw-r--r-- | src/database.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/database.c b/src/database.c index 340f59b2..714c4b1a 100644 --- a/src/database.c +++ b/src/database.c @@ -212,7 +212,7 @@ log_database_get_previous_chat(const gchar *const contact_barejid) sqlite3_stmt *stmt = NULL; char *query; - if (asprintf(&query, "SELECT `message`, `timestamp`, `from_jid` from `ChatLogs` WHERE `from_jid` = '%s' OR `to_jid` = '%s' ORDER BY `timestamp` ASC LIMIT 10", contact_barejid, contact_barejid) == -1) { + if (asprintf(&query, "SELECT * FROM (SELECT `message`, `timestamp`, `from_jid` from `ChatLogs` WHERE `from_jid` = '%s' OR `to_jid` = '%s' ORDER BY `timestamp` DESC LIMIT 10) ORDER BY `timestamp` ASC;", contact_barejid, contact_barejid) == -1) { log_error("log_database_get_previous_chat(): SQL query. could not allocate memory"); return NULL; } |