aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/scripts/update_lastmessage.sql1
1 files changed, 1 insertions, 0 deletions
diff --git a/contrib/scripts/update_lastmessage.sql b/contrib/scripts/update_lastmessage.sql
new file mode 100644
index 00000000..3a843408
--- /dev/null
+++ b/contrib/scripts/update_lastmessage.sql
@@ -0,0 +1 @@
+UPDATE users, (SELECT users.`id` uid, MAX(COALESCE(replies.ts, messages.ts)) lastt FROM messages LEFT JOIN replies ON messages.`message_id`=replies.`message_id` LEFT JOIN users ON users.id=messages.user_id GROUP BY users.`id`) res SET users.lastmessage = res.lastt WHERE users.`id` = res.uid;