rank the 5 limited posts normally

pull/232/head
Aevann 2024-08-02 16:37:48 +03:00
parent 6f826d5032
commit 6b4cb964e7
3 changed files with 12 additions and 0 deletions

View File

@ -453,3 +453,10 @@ class Post(Base):
return False
return True
@property
@lazy
def hot_ranking(self):
ti = int(time.time()) + 3600
metric = self.realupvotes + 1 + self.comment_count/5
return -1000000*(metric / pow(((ti - self.created_utc)/1000), 1.4))

View File

@ -182,6 +182,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
if posts1:
posts2 = posts.filter(Post.hole.in_(limited_WPD_holes)).offset(5 * (page - 1)).limit(5).all()
posts = posts1 + posts2
posts.sort(key=lambda x: x.hot_ranking)
else:
elapsed_pages = posts.filter(Post.hole.notin_(limited_WPD_holes)).count() / (size - 5)
posts = posts.filter(Post.hole.in_(limited_WPD_holes)).offset(5 * elapsed_pages + size * (page - 1 - elapsed_pages)).limit(size).all()

View File

@ -34,6 +34,10 @@
{{macros.reports(p, 'post')}}
{% if v.id == AEVANN_ID %}
wtf {{p.hot_ranking}}
{% endif %}
<div id="post-{{p.id}}" class="actual-post card {% if u and p.profile_pinned %}pinned-to-profile{% endif %} {% if p.ghost %}ghost-post{% endif %} {% if p.unread %}unread{% endif %} {% if p.is_banned %} banned{% endif %}{% if p.deleted_utc %} deleted{% endif %}{% if p.pinned %} pinned{% endif %}{% if voted == 1 %} upvoted{% elif voted==-1 %} downvoted{% endif %}{% if p.nsfw %} nsfw{% endif %}">
<div class="d-flex flex-row-reverse flex-md-row flex-nowrap" style="align-items:flex-start">
<div class="voting my-2 d-none d-md-flex pr-2">