Repository: pypi/warehouse

Issue:
Sort user page project list by last release date
Right now the project listing on user page is sorted alphabetically:

![screenshot from 2017-07-19 01-42-04](https://user-images.githubusercontent.com/130193/28358448-c0df6b58-6c23-11e7-8194-8715a6686302.png)

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](https://warehouse.pypa.io/development/getting-started/). If you are working on this issue and have questions, please feel free to ask them here, [`#pypa-dev` on Freenode](https://webchat.freenode.net/?channels=%23pypa-dev), or the [pypa-dev mailing list](https://groups.google.com/forum/#!forum/pypa-dev).


Discussion:
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`](https://github.com/pypa/warehouse/blob/master/warehouse/accounts/views.py) to sort the projects by release date as follows:

```diff
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 `Project`s instead of `Release`s as it originally did, so the template at [`warehouse/templates/accounts/profile.html`](https://github.com/pypa/warehouse/blob/master/warehouse/templates/accounts/profile.html#L55-L63) will need to be updated as well.

Resolving patch:
diff --git a/warehouse/accounts/views.py b/warehouse/accounts/views.py
--- a/warehouse/accounts/views.py
+++ b/warehouse/accounts/views.py
@@ -80,12 +80,11 @@ def profile(user, request):
         )
 
     projects = (
-        request.db.query(Release)
-                  .options(joinedload(Release.project))
-                  .join(Project)
-                  .distinct(Project.name)
+        request.db.query(Project)
                   .filter(Project.users.contains(user))
-                  .order_by(Project.name, Release._pypi_ordering.desc())
+                  .options(joinedload(Project.releases))
+                  .join(Release)
+                  .order_by(Release.created.desc())
                   .all()
     )
 


Test patch: