Amend last_active and post_count for newly-discovered remote communities

This commit is contained in:
freamon 2024-03-15 22:51:27 +00:00
parent c5f0d5175a
commit 98d381d94d

View file

@ -17,7 +17,7 @@ from app.models import Community, File, BannedInstances, PostReply, PostVote, Po
from app.utils import get_request, gibberish, markdown_to_html, domain_from_url, allowlist_html, \
html_to_markdown, is_image_url, ensure_directory_exists, inbox_domain, post_ranking, shorten_string, parse_page, \
remove_tracking_from_link, ap_datetime, instance_banned
from sqlalchemy import func
from sqlalchemy import func, desc
import os
@ -118,8 +118,8 @@ def retrieve_mods_and_backfill(community_id: int):
if activities_processed >= 50:
break
c = Community.query.get(community.id)
c.post_count = activities_processed
c.last_active = site.last_active = utcnow()
if c.post_count > 0:
c.last_active = Post.query.filter(Post.community_id == community_id).order_by(desc(Post.posted_at)).first().posted_at
db.session.commit()