From d7e7d7941937b73d8e1cb311efcdfb2a2163cafe Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Thu, 8 Feb 2024 12:46:41 +1300 Subject: [PATCH] calculate local post stats --- app/activitypub/util.py | 4 ++-- app/post/routes.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/activitypub/util.py b/app/activitypub/util.py index 3563f25d..94f0f778 100644 --- a/app/activitypub/util.py +++ b/app/activitypub/util.py @@ -60,11 +60,11 @@ def active_month(): def local_posts(): - return db.session.execute(text('SELECT COUNT(id) as c FROM "post" WHERE ap_id is null')).scalar() + return db.session.execute(text('SELECT COUNT(id) as c FROM "post" WHERE instance_id = 1')).scalar() def local_comments(): - return db.session.execute(text('SELECT COUNT(id) as c FROM "post_reply" WHERE ap_id is null')).scalar() + return db.session.execute(text('SELECT COUNT(id) as c FROM "post_reply" WHERE instance_id = 1')).scalar() def send_activity(sender: User, host: str, content: str): diff --git a/app/post/routes.py b/app/post/routes.py index a0ef2cb5..25bd8fa8 100644 --- a/app/post/routes.py +++ b/app/post/routes.py @@ -415,7 +415,7 @@ def add_reply(post_id: int, comment_id: int): community_id=post.community.id, body=form.body.data, body_html=markdown_to_html(form.body.data), body_html_safe=True, from_bot=current_user.bot, up_votes=1, nsfw=post.nsfw, nsfl=post.nsfl, - notify_author=form.notify_author.data) + notify_author=form.notify_author.data, instance_id=1) db.session.add(reply) if in_reply_to.notify_author and current_user.id != in_reply_to.user_id and in_reply_to.author.ap_id is None: # todo: check if replier is blocked notification = Notification(title=_('Reply from %(name)s', name=current_user.display_name()), user_id=in_reply_to.user_id,