Warehouse: Sort user page project list by last release date

Created on 19 Jul 2017  路  4Comments  路  Source: pypa/warehouse

Right now the project listing on user page is sorted alphabetically:

screenshot from 2017-07-19 01-42-04

I just released chert a couple days ago, but it's below ashes, released months ago.

Sorting by popularity, pinning, and other configurability might make sense later, but in the meantime I think a more sensible sort order would be by the recency of release. Makes the content seem fresher and more social, which is kind of the point of a user page with a big honkin gravatar, I figure.

Happy to contribute this if folks seem to agree.


Good First Issue: This issue is good for first time contributors. If there is not a corresponding pull request for this issue, it is up for grabs. For directions for getting set up, see our Getting Started Guide. If you are working on this issue and have questions, please feel free to ask them here, #pypa-dev on Freenode, or the pypa-dev mailing list.

feature request good first issue

Most helpful comment

Just want to point out to any potential contributors that this issue is still up for grabs.

All 4 comments

That seems reasonable to me.

#2213 addresses this, give it a gander when you get a chance :)

Just want to point out to any potential contributors that this issue is still up for grabs.

Since this issue has been around for a while without being resolved, here's a pointer in the right direction for any potential first-time contributors:

We can modify the query in warehouse/accounts/views.py to sort the projects by release date as follows:

diff --git a/warehouse/accounts/views.py b/warehouse/accounts/views.py
index c6ea043..26a636a 100644
--- a/warehouse/accounts/views.py
+++ b/warehouse/accounts/views.py
@@ -75,13 +75,12 @@ def profile(user, request):
         )

     projects = (
-        request.db.query(Release)
-                  .options(joinedload(Release.project))
-                  .join(Project)
-                  .distinct(Project.name)
-                  .filter(Project.users.contains(user))
-                  .order_by(Project.name, Release._pypi_ordering.desc())
-                  .all()
+        request.db.query(Project)
+                  .filter(Project.users.contains(user))
+                  .options(joinedload(Project.releases))
+                  .join(Release)
+                  .order_by(Release.created.desc())
+                  .all()
     )

     return {"user": user, "projects": projects}

However this (properly) returns Projects instead of Releases as it originally did, so the template at warehouse/templates/accounts/profile.html will need to be updated as well.

Was this page helpful?
0 / 5 - 0 ratings