start the new topics route and view
This commit is contained in:
@@ -111,24 +111,16 @@ class Topics(Model):
|
||||
q = """
|
||||
SELECT
|
||||
topics.id, topics.name, topics.slug, topics.description, topics.is_locked,
|
||||
users.username AS latest_thread_username,
|
||||
users.display_name AS latest_thread_display_name,
|
||||
threads.title AS latest_thread_title,
|
||||
threads.slug AS latest_thread_slug,
|
||||
threads.created_at AS latest_thread_created_at
|
||||
COUNT(DISTINCT threads.id) as threads_count,
|
||||
COUNT(posts.id) AS posts_count,
|
||||
MAX(posts.created_at) as latest_post_timestamp
|
||||
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
|
||||
ORDER BY
|
||||
topics.sort_order ASC"""
|
||||
threads ON threads.topic_id = topics.id
|
||||
LEFT JOIN
|
||||
posts ON posts.thread_id = threads.id
|
||||
GROUP BY topics.id ORDER BY topics.sort_order ASC"""
|
||||
return db.query(q)
|
||||
|
||||
def get_threads(self, per_page, page, sort_by = 'activity'):
|
||||
|
||||
Reference in New Issue
Block a user