From 1f53ce33a83dfe1b1533a7fe871ca12c328f751f Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 11 Sep 2021 07:52:56 -0700 Subject: [PATCH] Fixes user stats reporting --- bookwyrm/views/wellknown.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/bookwyrm/views/wellknown.py b/bookwyrm/views/wellknown.py index 426d0cdcf..096d2ed30 100644 --- a/bookwyrm/views/wellknown.py +++ b/bookwyrm/views/wellknown.py @@ -56,17 +56,17 @@ def nodeinfo_pointer(_): @require_GET def nodeinfo(_): """basic info about the server""" - status_count = models.Status.objects.filter(user__local=True).count() - user_count = models.User.objects.filter(local=True).count() + status_count = models.Status.objects.filter(user__local=True, deleted=False).count() + user_count = models.User.objects.filter(is_active=True, local=True).count() month_ago = timezone.now() - relativedelta(months=1) last_month_count = models.User.objects.filter( - local=True, last_active_date__gt=month_ago + is_active=True, local=True, last_active_date__gt=month_ago ).count() six_months_ago = timezone.now() - relativedelta(months=6) six_month_count = models.User.objects.filter( - local=True, last_active_date__gt=six_months_ago + is_active=True, local=True, last_active_date__gt=six_months_ago ).count() site = models.SiteSettings.get() @@ -91,8 +91,8 @@ def nodeinfo(_): @require_GET def instance_info(_): """let's talk about your cool unique instance""" - user_count = models.User.objects.filter(local=True).count() - status_count = models.Status.objects.filter(user__local=True).count() + user_count = models.User.objects.filter(is_active=True, local=True).count() + status_count = models.Status.objects.filter(user__local=True, deleted=False).count() site = models.SiteSettings.get() logo_path = site.logo_small or "images/logo-small.png" @@ -111,7 +111,7 @@ def instance_info(_): "thumbnail": logo, "languages": ["en"], "registrations": site.allow_registration, - "approval_required": False, + "approval_required": site.allow_registration and site.allow_invite_requests, "email": site.admin_email, } ) @@ -120,7 +120,9 @@ def instance_info(_): @require_GET def peers(_): """list of federated servers this instance connects with""" - names = models.FederatedServer.objects.values_list("server_name", flat=True) + names = models.FederatedServer.objects.values_list( + "server_name", flat=True, status="federated" + ) return JsonResponse(list(names), safe=False)