add unread count to thread title in topic view and thread view

This commit is contained in:
2025-08-17 15:15:06 +03:00
parent 1f80ed7ca5
commit 6dd9f5bf65
5 changed files with 31 additions and 5 deletions

View File

@ -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'