ranking tweak

This commit is contained in:
rimu 2024-02-21 19:56:03 +13:00
parent eae56a6882
commit 8fcf2e3a77

View file

@ -20,7 +20,8 @@ from sqlalchemy_searchable import search
from app.utils import render_template, get_setting, gibberish, request_etag_matches, return_304, blocked_domains, \ from app.utils import render_template, get_setting, gibberish, request_etag_matches, return_304, blocked_domains, \
ap_datetime, ip_address, retrieve_block_list, shorten_string, markdown_to_text, user_filters_home, \ ap_datetime, ip_address, retrieve_block_list, shorten_string, markdown_to_text, user_filters_home, \
joined_communities, moderating_communities, parse_page, theme_list, get_request joined_communities, moderating_communities, parse_page, theme_list, get_request
from app.models import Community, CommunityMember, Post, Site, User, utcnow, Domain, Topic, File, Instance, InstanceRole from app.models import Community, CommunityMember, Post, Site, User, utcnow, Domain, Topic, File, Instance, \
InstanceRole, Notification
from PIL import Image from PIL import Image
import pytesseract import pytesseract
@ -102,7 +103,7 @@ def home_page(type, sort):
# Sorting # Sorting
if sort == 'hot': if sort == 'hot':
posts = posts.order_by(desc(Post.ranking)) posts = posts.order_by(desc(Post.ranking)).order_by(desc(Post.posted_at))
elif sort == 'top': elif sort == 'top':
posts = posts.filter(Post.posted_at > utcnow() - timedelta(days=1)).order_by(desc(Post.score)) posts = posts.filter(Post.posted_at > utcnow() - timedelta(days=1)).order_by(desc(Post.score))
elif sort == 'new': elif sort == 'new':
@ -256,7 +257,7 @@ def list_files(directory):
@bp.route('/test') @bp.route('/test')
def test(): def test():
u = User.query.get(1) u = User.query.filter(User.email_unread == True).join(Notification, Notification.user_id == User.id).filter()
return 'ok' return 'ok'