add markup to topics list view

This commit is contained in:
2025-05-22 01:46:08 +03:00
parent 9b42d05174
commit 1cb9262ad7
5 changed files with 115 additions and 13 deletions

View File

@ -22,7 +22,25 @@ local ThreadCreateError = {
}
app:get("all_topics", "", function(self)
self.topic_list = db.query("select * from topics limit 25;")
self.topic_list = db.query([[
SELECT
topics.name, topics.slug, topics.description, topics.is_locked,
users.username AS latest_thread_username,
threads.title AS latest_thread_title,
threads.slug AS latest_thread_slug,
threads.created_at AS latest_thread_created_at
FROM
topics
LEFT JOIN (
SELECT
*,
row_number() OVER (PARTITION BY threads.topic_id ORDER BY threads.created_at DESC) as rn
FROM
threads
) threads ON threads.topic_id = topics.id AND threads.rn = 1
LEFT JOIN
users on users.id = threads.user_id
]])
self.me = util.get_logged_in_user_or_transient(self)
return {render = "topics.topics"}
end)