- 登录后可管理标记收藏
+ 登录后可管理标记收藏
{% endif %}
diff --git a/users/account.py b/users/account.py
index a89cff29..8837b2c0 100644
--- a/users/account.py
+++ b/users/account.py
@@ -24,6 +24,7 @@ from django.contrib import messages
from journal.models import remove_data_by_user
from django.db.models import Q
from django.core.cache import cache
+from django.db.models import Count
# the 'login' page that user can see
@@ -35,13 +36,13 @@ def login(request):
sites = cache.get(cache_key, [])
if not sites:
sites = list(
- MastodonApplication.objects.all()
- .exclude(Q(domain_name__contains="@"))
- .exclude(Q(domain_name__contains=":"))
- .order_by("domain_name")
- .values_list("domain_name")
+ User.objects.filter(is_active=True)
+ .values("mastodon_site")
+ .annotate(total=Count("mastodon_site"))
+ .order_by("-total")
+ .values_list("mastodon_site", flat=True)
)
- cache.set(cache_key, sites, timeout=3600)
+ cache.set(cache_key, sites, timeout=3600 * 8)
# store redirect url in the cookie
if request.GET.get("next"):
request.session["next_url"] = request.GET.get("next")