forked from rDrama/rDrama
1
0
Fork 0

remove bump sort since it times out when combined with the "all" filter

master
Aevann 2023-07-22 19:00:25 +03:00
parent a2106d191a
commit 6f6c59e7b3
4 changed files with 1 additions and 7 deletions

View File

@ -71,8 +71,6 @@ class Post(Base):
subr = relationship("Sub", primaryjoin="foreign(Post.sub)==remote(Sub.name)")
options = relationship("PostOption", order_by="PostOption.id")
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())
super().__init__(*args, **kwargs)

View File

@ -322,7 +322,7 @@ THEMES = ["4chan","classic","classic_dark","coffee","dark","dramblr","light","mi
LIGHT_THEMES = ["4chan","classic","coffee","light","win98"]
BACKGROUND_CATEGORIES = ["glitter", "anime", "fantasy", "solarpunk", "pixelart"]
COMMENT_SORTS = ["hot", "new", "old", "top", "bottom", "controversial", "saves"]
SORTS = COMMENT_SORTS + ["bump", "comments", "views", "subscriptions", "saves"]
SORTS = COMMENT_SORTS + ["comments", "views", "subscriptions", "saves"]
TIME_FILTERS = ["hour", "day", "week", "month", "year", "all"]
PAGE_SIZES = (10, 25, 50, 100)

View File

@ -33,8 +33,6 @@ def sort_objects(sort, objects, cls):
return objects.order_by(-1000000*(metric + 1)/(func.power(((ti - cls.created_utc)/1000), 1.35)), cls.created_utc.desc())
elif sort == "views" and cls.__name__ == "Post":
return objects.order_by(cls.views.desc(), cls.created_utc.desc())
elif sort == "bump" and cls.__name__ == "Post":
return objects.filter(cls.comment_count > 1).order_by(cls.bump_utc.desc(), cls.created_utc.desc())
elif sort == "comments" and cls.__name__ == "Post":
return objects.order_by(cls.comment_count.desc(), cls.created_utc.desc())
elif sort == "subscriptions" and cls.__name__ == "Post":

View File

@ -106,7 +106,6 @@
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton2" data-bs-toggle="dropdown">
{% if sort=="hot" %}<i class="fas fa-fire mr-1"></i>{% endif %}
{% if sort=="views" %}<i class="fas fa-eye mr-1"></i>{% endif %}
{% if sort=="bump" %}<i class="fas fa-arrow-up mr-1"></i>{% endif %}
{% if sort=="top" %}<i class="fas fa-arrow-alt-circle-up mr-1"></i>{% endif %}
{% if sort=="bottom" %}<i class="fas fa-arrow-alt-circle-down mr-1"></i>{% endif %}
{% if sort=="new" %}<i class="fas fa-sparkles mr-1"></i>{% endif %}
@ -120,7 +119,6 @@
<div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px;">
{% if sort != "hot" %}<a class="dropdown-item" href="?sort=hot&t={{t}}"><i class="fas fa-fire mr-2"></i>Hot</a>{% endif %}
{% if sort != "views" %}<a class="dropdown-item" href="?sort=views&t={{t}}"><i class="fas fa-eye mr-2"></i>Views</a>{% endif %}
{% if sort != "bump" %}<a class="dropdown-item" href="?sort=bump&t={{t}}"><i class="fas fa-arrow-up mr-2"></i>Bump</a>{% endif %}
{% if sort != "top" %}<a class="dropdown-item" href="?sort=top&t={{t}}"><i class="fas fa-arrow-alt-circle-up mr-2"></i>Top</a>{% endif %}
{% if sort != "bottom" %}<a class="dropdown-item" href="?sort=bottom&t={{t}}"><i class="fas fa-arrow-alt-circle-down mr-2"></i>Bottom</a>{% endif %}
{% if sort != "new" %}<a class="dropdown-item" href="?sort=new&t={{t}}"><i class="fas fa-sparkles mr-2"></i>New</a>{% endif %}