tidy up calls to obsolete post_ranking

This commit is contained in:
rimu 2024-10-22 19:51:37 +13:00
parent 2aeac58f5e
commit 156c328c6f
5 changed files with 10 additions and 14 deletions

View file

@ -42,7 +42,7 @@ from app.utils import get_setting, render_template, allowlist_html, markdown_to_
request_etag_matches, return_304, instance_banned, can_create_post, can_upvote, can_downvote, user_filters_posts, \
joined_communities, moderating_communities, blocked_domains, mimetype_from_url, blocked_instances, \
community_moderators, communities_banned_from, show_ban_message, recently_upvoted_posts, recently_downvoted_posts, \
blocked_users, post_ranking, languages_for_form, english_language_id, menu_topics, add_to_modlog, \
blocked_users, languages_for_form, menu_topics, add_to_modlog, \
blocked_communities, remove_tracking_from_link, piefed_markdown_to_lemmy_markdown, ensure_directory_exists
from feedgen.feed import FeedGenerator
from datetime import timezone, timedelta

View file

@ -15,10 +15,10 @@ from app.activitypub.util import find_actor_or_create, actor_json_to_model, post
find_hashtag_or_create
from app.constants import POST_TYPE_ARTICLE, POST_TYPE_LINK, POST_TYPE_IMAGE, POST_TYPE_VIDEO, NOTIF_POST, \
POST_TYPE_POLL
from app.models import Community, File, BannedInstances, PostReply, PostVote, Post, utcnow, CommunityMember, Site, \
Instance, Notification, User, ActivityPubLog, NotificationSubscription, Language, Tag, PollChoice, Poll
from app.utils import get_request, gibberish, markdown_to_html, domain_from_url, allowlist_html, \
is_image_url, ensure_directory_exists, inbox_domain, post_ranking, shorten_string, parse_page, \
from app.models import Community, File, BannedInstances, PostReply, Post, utcnow, CommunityMember, Site, \
Instance, Notification, User, ActivityPubLog, NotificationSubscription, PollChoice, Poll
from app.utils import get_request, gibberish, markdown_to_html, domain_from_url, \
is_image_url, ensure_directory_exists, shorten_string, \
remove_tracking_from_link, ap_datetime, instance_banned, blocked_phrases, url_to_thumbnail_file, opengraph_parse, \
piefed_markdown_to_lemmy_markdown
from sqlalchemy import func, desc, text
@ -133,7 +133,7 @@ def retrieve_peertube_mods_and_backfill(community_id: int, mods: list):
if user:
post = post_json_to_model(activity_log, video_data, user, community)
post.ap_announce_id = activity['id']
post.ranking = post_ranking(post.score, post.posted_at)
post.ranking = post.post_ranking(post.score, post.posted_at)
else:
activity_log.exception_message = 'Could not find or create actor'
db.session.commit()
@ -197,7 +197,7 @@ def retrieve_mods_and_backfill(community_id: int):
if post:
post.ap_create_id = activity['object']['id']
post.ap_announce_id = activity['id']
post.ranking = post_ranking(post.score, post.posted_at)
post.ranking = post.post_ranking(post.score, post.posted_at)
if post.url:
other_posts = Post.query.filter(Post.id != post.id, Post.url == post.url, Post.deleted == False,
Post.posted_at > post.posted_at - timedelta(days=3),
@ -409,7 +409,7 @@ def save_post(form, post: Post, type: int):
post.score = 1
if current_user.reputation < -100:
post.score = -1
post.ranking = post_ranking(post.score, utcnow())
post.ranking = post.post_ranking(post.score, utcnow())
# Filter by phrase
blocked_phrases_list = blocked_phrases()

View file

@ -1134,7 +1134,7 @@ class Post(db.Model):
make_image_sizes, notify_about_post
from app.utils import allowlist_html, markdown_to_html, html_to_text, microblog_content_to_title, blocked_phrases, \
is_image_url, is_video_url, domain_from_url, opengraph_parse, shorten_string, remove_tracking_from_link, \
is_video_hosting_site, post_ranking, communities_banned_from
is_video_hosting_site, communities_banned_from
microblog = False
if 'name' not in request_json['object']: # Microblog posts

View file

@ -27,7 +27,7 @@ from app.models import Post, PostReply, \
from app.post import bp
from app.utils import get_setting, render_template, allowlist_html, markdown_to_html, validation_required, \
shorten_string, markdown_to_text, gibberish, ap_datetime, return_304, \
request_etag_matches, ip_address, user_ip_banned, instance_banned, can_downvote, can_upvote, post_ranking, \
request_etag_matches, ip_address, user_ip_banned, instance_banned, \
reply_already_exists, reply_is_just_link_to_gif_reaction, moderating_communities, joined_communities, \
blocked_instances, blocked_domains, community_moderators, blocked_phrases, show_ban_message, recently_upvoted_posts, \
recently_downvoted_posts, recently_upvoted_post_replies, recently_downvoted_post_replies, reply_is_stupid, \

View file

@ -898,10 +898,6 @@ def topic_tree() -> List:
return [topic for topic in topics_dict.values() if topic['topic'].parent_id is None]
def post_ranking(score, date: datetime):
return Post.post_ranking(score, date)
def opengraph_parse(url):
if '?' in url:
url = url.split('?')