new user page
This commit is contained in:
@ -81,6 +81,23 @@ app:get("user", "/:username", function(self)
|
||||
end
|
||||
end
|
||||
|
||||
self.stats = db.query([[
|
||||
SELECT
|
||||
COUNT(posts.id) AS post_count,
|
||||
COUNT(DISTINCT threads.id) AS thread_count,
|
||||
MAX(threads.title) FILTER (WHERE threads.created_at = latest.created_at) AS latest_thread_title,
|
||||
MAX(threads.slug) FILTER (WHERE threads.created_at = latest.created_at) AS latest_thread_slug
|
||||
FROM users
|
||||
LEFT JOIN posts ON posts.user_id = users.id
|
||||
LEFT JOIN threads ON threads.user_id = users.id
|
||||
LEFT JOIN (
|
||||
SELECT user_id, MAX(created_at) AS created_at
|
||||
FROM threads
|
||||
GROUP BY user_id
|
||||
) latest ON latest.user_id = users.id
|
||||
WHERE users.id = ?
|
||||
]], user.id)[1]
|
||||
|
||||
self.latest_posts = db.query([[
|
||||
SELECT
|
||||
posts.id, posts.created_at, post_history.content, post_history.edited_at, threads.title AS thread_title, topics.name as topic_name, threads.slug as thread_slug
|
||||
|
Reference in New Issue
Block a user