add unread count to thread title in topic view and thread view
This commit is contained in:
@ -178,7 +178,7 @@ class Topics(Model):
|
||||
|
||||
q = """
|
||||
SELECT
|
||||
threads.title, threads.slug, threads.created_at, threads.is_locked, threads.is_stickied,
|
||||
threads.id, threads.title, threads.slug, threads.created_at, threads.is_locked, threads.is_stickied,
|
||||
users.username AS started_by,
|
||||
u.username AS latest_post_username,
|
||||
ph.content AS latest_post_content,
|
||||
@ -251,6 +251,13 @@ class Avatars(Model):
|
||||
class Subscriptions(Model):
|
||||
table = "subscriptions"
|
||||
|
||||
def get_unread_count(self):
|
||||
q = """SELECT COUNT(*) AS unread_count
|
||||
FROM posts
|
||||
LEFT JOIN subscriptions ON subscriptions.thread_id = posts.thread_id
|
||||
WHERE subscriptions.user_id = ? AND posts.created_at > subscriptions.last_seen"""
|
||||
return db.fetch_one(q, self.user_id)['unread_count']
|
||||
|
||||
class APIRateLimits(Model):
|
||||
table = 'api_rate_limits'
|
||||
|
||||
|
Reference in New Issue
Block a user