Paginate thread list

This commit is contained in:
David Hoppenbrouwers
2022-10-09 16:09:21 +02:00
parent 3bcbbf844d
commit c17a76d18f
3 changed files with 28 additions and 5 deletions

View File

@@ -35,15 +35,18 @@ class DB:
(forum_id,)
).fetchone()
def get_threads(self, forum_id):
def get_threads(self, forum_id, offset, limit):
return self._db().execute('''
select t.thread_id, title, t.create_time, t.update_time, t.author_id, name, count(c.thread_id)
from threads t, users
left join comments c on t.thread_id = c.thread_id
where forum_id = ? and user_id = t.author_id
group by t.thread_id
order by t.update_time desc
limit ?
offset ?
''',
(forum_id,)
(forum_id, limit, offset)
)
def get_thread(self, thread):