Use recently active as the default sort order

This commit is contained in:
Mouse Reeve 2021-09-28 15:51:49 -07:00
parent 128a5c5754
commit 21fee19b42
3 changed files with 6 additions and 6 deletions

View file

@ -8,7 +8,7 @@
{% trans "Local users" %} {% trans "Local users" %}
</label> </label>
<label class="is-block"> <label class="is-block">
<input type="radio" class="radio" name="scope" value="federated" {% if not request.GET.sort or request.GET.scope == "federated" %}checked{% endif %}> <input type="radio" class="radio" name="scope" value="federated" {% if request.GET.scope == "federated" %}checked{% endif %}>
{% trans "Federated community" %} {% trans "Federated community" %}
</label> </label>
{% endblock %} {% endblock %}

View file

@ -5,8 +5,8 @@
<label class="label" for="id_sort">{% trans "Order by" %}</label> <label class="label" for="id_sort">{% trans "Order by" %}</label>
<div class="select"> <div class="select">
<select name="sort" id="id_sort"> <select name="sort" id="id_sort">
<option value="suggested" {% if not request.GET.sort or request.GET.sort == "suggested" %}checked{% endif %}>{% trans "Suggested" %}</option> <option value="recent" {% if request.GET.sort == "recent" %}selected{% endif %}>{% trans "Recently active" %}</option>
<option value="recent" {% if request.GET.sort == "suggested" %}checked{% endif %}>{% trans "Recently active" %}</option> <option value="suggested" {% if request.GET.sort == "suggested" %}selected{% endif %}>{% trans "Suggested" %}</option>
</select> </select>
</div> </div>
{% endblock %} {% endblock %}

View file

@ -25,10 +25,10 @@ class Directory(View):
users = suggested_users.get_annotated_users(request.user, **filters) users = suggested_users.get_annotated_users(request.user, **filters)
sort = request.GET.get("sort") sort = request.GET.get("sort")
if sort == "recent": if sort == "suggested":
users = users.order_by("-last_active_date")
else:
users = users.order_by("-mutuals", "-last_active_date") users = users.order_by("-mutuals", "-last_active_date")
else:
users = users.order_by("-last_active_date")
paginated = Paginator(users, 12) paginated = Paginator(users, 12)