add user started threads view
This commit is contained in:
@@ -54,6 +54,14 @@ class Users(Model):
|
||||
q = f'{Posts.FULL_POSTS_QUERY} WHERE posts.user_id = ? ORDER BY posts.created_at DESC LIMIT ? OFFSET ?'
|
||||
return db.query(q, self.id, per_page, (page - 1) * per_page)
|
||||
|
||||
def get_started_threads(self, per_page: int, page: int) -> list:
|
||||
q = f"""{Posts.FULL_POSTS_QUERY} WHERE threads.user_id = ? AND posts.created_at = (
|
||||
SELECT MIN(p2.created_at)
|
||||
FROM posts p2
|
||||
WHERE p2.thread_id = posts.thread_id
|
||||
) ORDER BY threads.created_at DESC LIMIT ? OFFSET ?"""
|
||||
return db.query(q, self.id, per_page, (page - 1) * per_page)
|
||||
|
||||
def get_all_subscriptions(self):
|
||||
q = """
|
||||
SELECT threads.title AS thread_title, threads.slug AS thread_slug
|
||||
@@ -289,6 +297,7 @@ class Posts(Model):
|
||||
users.id AS user_id, post_history.original_markup,
|
||||
users.signature_rendered, threads.slug AS thread_slug,
|
||||
threads.is_locked AS thread_is_locked, threads.title AS thread_title,
|
||||
topics.id AS topic_id, topics.name AS topic_name,
|
||||
COALESCE(user_badges.badges_json, '[]') AS badges_json
|
||||
FROM
|
||||
posts
|
||||
@@ -296,6 +305,8 @@ class Posts(Model):
|
||||
post_history ON posts.current_revision_id = post_history.id
|
||||
JOIN
|
||||
users ON posts.user_id = users.id
|
||||
JOIN
|
||||
topics ON threads.topic_id = topics.id
|
||||
JOIN
|
||||
threads ON posts.thread_id = threads.id
|
||||
LEFT JOIN
|
||||
|
||||
Reference in New Issue
Block a user