better wpd frontpage?

master
Aevann 2024-07-23 02:21:48 +03:00
parent e1d1381dee
commit a93e169780
1 changed files with 9 additions and 6 deletions

View File

@ -167,6 +167,8 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
if v and v.admin_level < PERMS['USER_SHADOWBAN']:
posts = posts.join(Post.author).filter(or_(User.id == v.id, User.shadowbanned == None))
total = posts.count()
posts = sort_objects(sort, posts, Post)
if v: size = v.frontsize or 0
@ -180,13 +182,14 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
if SITE_NAME == 'WPD' and sort == "hot" and hole == None and not is_community:
size -= 3
posts1 = posts.filter(Post.hole.notin_(LIMITED_WPD_HOLES))
total = posts1.count()
posts1 = posts1.offset(size * (page - 1)).limit(size).all()
posts2 = posts.filter(Post.hole.in_(LIMITED_WPD_HOLES)).offset(3 * (page - 1)).limit(3).all()
posts = posts1 + posts2
posts1 = posts.filter(Post.hole.notin_(LIMITED_WPD_HOLES)).offset((size) * (page - 1)).limit(size).all()
if posts1:
posts2 = posts.filter(Post.hole.in_(LIMITED_WPD_HOLES)).offset(3 * (page - 1)).limit(3).all()
posts = posts1 + posts2
else:
elapsed_pages = posts.filter(Post.hole.notin_(LIMITED_WPD_HOLES)).count() / size
posts = posts.filter(Post.hole.in_(LIMITED_WPD_HOLES)).offset(3 * elapsed_pages + size * (page - 1 - elapsed_pages)).limit(size).all()
else:
total = posts.count()
posts = posts.offset(size * (page - 1)).limit(size).all()
if pins and page == 1 and not gt and not lt: