aboutsummaryrefslogtreecommitdiff
path: root/contrib/scripts
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-04-15 22:48:32 +0300
committerGravatar Vitaly Takmazov2018-04-15 22:48:32 +0300
commit4bcb69153187f73d5a981db4a9c403622768af1b (patch)
treed65828b32c6917c908fa3399dd3ab138160dd609 /contrib/scripts
parent0aa64b3201df580918ba496e3df65f0b7dfdd41f (diff)
add script for lastmessage update
Diffstat (limited to 'contrib/scripts')
-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;