From 1425aa0db6535cea87a8f8e772c4ee9eb8d8bedc Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 6 Mar 2022 00:46:56 +0200 Subject: [PATCH] bump sortign --- files/classes/submission.py | 3 ++- files/routes/front.py | 4 ++++ files/templates/authforms.html | 2 +- files/templates/default.html | 4 ++-- files/templates/home.html | 2 ++ files/templates/log.html | 4 ++-- files/templates/login.html | 2 +- files/templates/login_2fa.html | 2 +- files/templates/settings.html | 2 +- files/templates/settings2.html | 4 ++-- files/templates/sign_up.html | 2 +- files/templates/sign_up_failed_ref.html | 2 +- files/templates/submit.html | 4 ++-- 13 files changed, 22 insertions(+), 15 deletions(-) diff --git a/files/classes/submission.py b/files/classes/submission.py index 9e81d2650..9cfa350a8 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -5,7 +5,7 @@ import time from urllib.parse import urlparse from flask import render_template from sqlalchemy import * -from sqlalchemy.orm import relationship +from sqlalchemy.orm import relationship, deferred from files.__main__ import Base from files.helpers.const import * from files.helpers.lazy import lazy @@ -61,6 +61,7 @@ class Submission(Base): comments = relationship("Comment", primaryjoin="Comment.parent_submission==Submission.id") subr = relationship("Sub", primaryjoin="foreign(Submission.sub)==remote(Sub.name)", viewonly=True) + bump_utc = deferred(Column(Integer, server_default=FetchedValue())) def __init__(self, *args, **kwargs): if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time()) diff --git a/files/routes/front.py b/files/routes/front.py index 2e055e922..bf0332e10 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -164,6 +164,8 @@ def front_all(v, sub=None, subdomain=None): sort=request.values.get("sort", defaultsorting) t=request.values.get('t', defaulttime) ccmode=request.values.get('ccmode', "false").lower() + + if sort == 'bump': t='all' if request.host == 'rdrama.net': defaultsubs = 'Exclude subs' else: defaultsubs = 'Include subs' @@ -324,6 +326,8 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false" if sort == "hot": ti = int(time.time()) + 3600 posts = posts.order_by(-1000000*(Submission.realupvotes + 1 + Submission.comment_count/5 + (func.length(Submission.body_html)-func.length(func.replace(Submission.body_html,'',''))))/(func.power(((ti - Submission.created_utc)/1000), 1.23))) + elif sort == "bump": + posts = posts.order_by(Submission.bump_utc.desc()) elif sort == "new": posts = posts.order_by(Submission.created_utc.desc()) elif sort == "old": diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 53d41840a..f7e8345e1 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -15,7 +15,7 @@ {% if v %} - + {% if v.agendaposter %} - + {% if SITE_NAME == 'Drama' and not request.path.startswith('/s/') %} {% endif %} @@ -35,7 +35,7 @@ {% endif %} {% else %} - + {% if SITE_NAME == 'Drama' and not request.path.startswith('/s/') %} {% endif %} diff --git a/files/templates/home.html b/files/templates/home.html index 6ab929379..12e97bb06 100644 --- a/files/templates/home.html +++ b/files/templates/home.html @@ -97,6 +97,7 @@