Skip to content

Commit efbbd53

Browse files
committed
Make async version for get_total_thread_pages
1 parent 8c44249 commit efbbd53

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

loading_sdk/async_api/client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,17 @@ async def get_total_thread_pages(self, thread_id):
527527
:type thread_id: str
528528
:rtype: dict
529529
"""
530-
pass
530+
531+
response = await self.get_thread(thread_id)
532+
533+
if response["code"] != 200:
534+
return response
535+
536+
thread_start = response["data"]["posts"][-1]
537+
replies = max(thread_start["replies"], 1)
538+
pages = math.ceil(replies / POSTS_PER_PAGE)
539+
540+
return pages
531541

532542
async def get_total_category_pages(self, category):
533543
"""Returns total pages of a forum category.

0 commit comments

Comments
 (0)