forked from MarseyWorld/MarseyWorld
fds
parent
1e620a02e8
commit
75d83b7a4b
|
@ -169,12 +169,6 @@ class Submission(Base):
|
||||||
def score(self):
|
def score(self):
|
||||||
return self.upvotes - self.downvotes
|
return self.upvotes - self.downvotes
|
||||||
|
|
||||||
@property
|
|
||||||
@lazy
|
|
||||||
def hotscore(self):
|
|
||||||
return 10000000*(self.upvotes - self.downvotes + 1)/(((self.age+3600)/1000)**(1.35))
|
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def fullname(self):
|
def fullname(self):
|
||||||
|
|
|
@ -171,10 +171,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
|
||||||
posts = posts.join(Submission.author).filter(User.shadowbanned == False)
|
posts = posts.join(Submission.author).filter(User.shadowbanned == False)
|
||||||
|
|
||||||
if sort == "hot":
|
if sort == "hot":
|
||||||
posts = sorted(posts.all(), key=lambda x: x.hotscore, reverse=True)
|
posts = posts.order_by(-10000000*(Submission.upvotes - Submission.downvotes + 1)/(((int(time.time()) - Submission.created_utc + 3600)/1000)*(1.35)))
|
||||||
firstrange = 25 * (page - 1)
|
|
||||||
secondrange = firstrange+100
|
|
||||||
posts = posts[firstrange:secondrange]
|
|
||||||
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":
|
||||||
|
@ -188,8 +185,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
|
||||||
elif sort == "comments":
|
elif sort == "comments":
|
||||||
posts = posts.order_by(Submission.comment_count.desc())
|
posts = posts.order_by(Submission.comment_count.desc())
|
||||||
|
|
||||||
if sort != "hot": posts = posts.offset(25 * (page - 1)).limit(26).all()
|
posts = posts.offset(25 * (page - 1)).limit(26).all()
|
||||||
|
|
||||||
|
|
||||||
next_exists = (len(posts) > 25)
|
next_exists = (len(posts) > 25)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue