master
Aevann1 2022-02-21 08:13:05 +02:00
parent fb8ec7a343
commit 34e29a6ab3
2 changed files with 2 additions and 3 deletions

View File

@ -5,7 +5,7 @@ import time
from urllib.parse import urlparse from urllib.parse import urlparse
from flask import render_template from flask import render_template
from sqlalchemy import * from sqlalchemy import *
from sqlalchemy.orm import relationship, deferred from sqlalchemy.orm import relationship
from files.__main__ import Base from files.__main__ import Base
from files.helpers.const import * from files.helpers.const import *
from files.helpers.lazy import lazy from files.helpers.lazy import lazy
@ -60,7 +60,6 @@ class Submission(Base):
comments = relationship("Comment", primaryjoin="Comment.parent_submission==Submission.id") comments = relationship("Comment", primaryjoin="Comment.parent_submission==Submission.id")
subr = relationship("Sub", primaryjoin="foreign(Submission.sub)==remote(Sub.name)", viewonly=True) subr = relationship("Sub", primaryjoin="foreign(Submission.sub)==remote(Sub.name)", viewonly=True)
comment_count_distinct = deferred(Column(Float, server_default=FetchedValue()))
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time()) if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())

View File

@ -322,7 +322,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false"
if sort == "hot": if sort == "hot":
ti = int(time.time()) + 3600 ti = int(time.time()) + 3600
posts = posts.order_by(-1000000*(Submission.realupvotes + 1 + Submission.comment_count_distinct/2 + (func.length(Submission.body_html)-func.length(func.replace(Submission.body_html,'</a>',''))))/(func.power(((ti - Submission.created_utc)/1000), 1.23))) posts = posts.order_by(-1000000*(Submission.realupvotes + 1 + Submission.comment_count/5 + (func.length(Submission.body_html)-func.length(func.replace(Submission.body_html,'</a>',''))))/(func.power(((ti - Submission.created_utc)/1000), 1.23)))
elif sort == "new": elif sort == "new":
posts = posts.order_by(Submission.created_utc.desc()) posts = posts.order_by(Submission.created_utc.desc())
elif sort == "old": elif sort == "old":