{"action":"created","issue":{"url":"https://api.github.com/repos/pypa/warehouse/issues/2206","repository_url":"https://api.github.com/repos/pypa/warehouse","labels_url":"https://api.github.com/repos/pypa/warehouse/issues/2206/labels{/name}","comments_url":"https://api.github.com/repos/pypa/warehouse/issues/2206/comments","events_url":"https://api.github.com/repos/pypa/warehouse/issues/2206/events","html_url":"https://github.com/pypa/warehouse/issues/2206","id":243966237,"number":2206,"title":"Sort user page project list by last release date","user":{"login":"mahmoud","id":130193,"avatar_url":"https://avatars0.githubusercontent.com/u/130193?v=4","gravatar_id":"","url":"https://api.github.com/users/mahmoud","html_url":"https://github.com/mahmoud","followers_url":"https://api.github.com/users/mahmoud/followers","following_url":"https://api.github.com/users/mahmoud/following{/other_user}","gists_url":"https://api.github.com/users/mahmoud/gists{/gist_id}","starred_url":"https://api.github.com/users/mahmoud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mahmoud/subscriptions","organizations_url":"https://api.github.com/users/mahmoud/orgs","repos_url":"https://api.github.com/users/mahmoud/repos","events_url":"https://api.github.com/users/mahmoud/events{/privacy}","received_events_url":"https://api.github.com/users/mahmoud/received_events","type":"User","site_admin":false},"labels":[{"id":378919429,"url":"https://api.github.com/repos/pypa/warehouse/labels/feature%20request","name":"feature request","color":"b60205","default":false},{"id":199106306,"url":"https://api.github.com/repos/pypa/warehouse/labels/good%20first%20issue","name":"good first issue","color":"009800","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-07-19T08:46:41Z","updated_at":"2018-02-09T22:35:36Z","closed_at":null,"author_association":"NONE","body":"Right now the project listing on user page is sorted alphabetically:\r\n\r\n![screenshot from 2017-07-19 01-42-04](https://user-images.githubusercontent.com/130193/28358448-c0df6b58-6c23-11e7-8194-8715a6686302.png)\r\n\r\nI just released chert a couple days ago, but it's below ashes, released months ago.\r\n\r\nSorting 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.\r\n\r\nHappy to contribute this if folks seem to agree."},"comment":{"url":"https://api.github.com/repos/pypa/warehouse/issues/comments/364589255","html_url":"https://github.com/pypa/warehouse/issues/2206#issuecomment-364589255","issue_url":"https://api.github.com/repos/pypa/warehouse/issues/2206","id":364589255,"user":{"login":"di","id":294415,"avatar_url":"https://avatars1.githubusercontent.com/u/294415?v=4","gravatar_id":"","url":"https://api.github.com/users/di","html_url":"https://github.com/di","followers_url":"https://api.github.com/users/di/followers","following_url":"https://api.github.com/users/di/following{/other_user}","gists_url":"https://api.github.com/users/di/gists{/gist_id}","starred_url":"https://api.github.com/users/di/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/di/subscriptions","organizations_url":"https://api.github.com/users/di/orgs","repos_url":"https://api.github.com/users/di/repos","events_url":"https://api.github.com/users/di/events{/privacy}","received_events_url":"https://api.github.com/users/di/received_events","type":"User","site_admin":false},"created_at":"2018-02-09T22:35:36Z","updated_at":"2018-02-09T22:35:36Z","author_association":"MEMBER","body":"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:\r\n\r\nWe 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:\r\n\r\n```diff\r\ndiff --git a/warehouse/accounts/views.py b/warehouse/accounts/views.py\r\nindex c6ea043..26a636a 100644\r\n--- a/warehouse/accounts/views.py\r\n+++ b/warehouse/accounts/views.py\r\n@@ -75,13 +75,12 @@ def profile(user, request):\r\n         )\r\n\r\n     projects = (\r\n-        request.db.query(Release)\r\n-                  .options(joinedload(Release.project))\r\n-                  .join(Project)\r\n-                  .distinct(Project.name)\r\n-                  .filter(Project.users.contains(user))\r\n-                  .order_by(Project.name, Release._pypi_ordering.desc())\r\n-                  .all()\r\n+        request.db.query(Project)\r\n+                  .filter(Project.users.contains(user))\r\n+                  .options(joinedload(Project.releases))\r\n+                  .join(Release)\r\n+                  .order_by(Release.created.desc())\r\n+                  .all()\r\n     )\r\n\r\n     return {\"user\": user, \"projects\": projects}\r\n```\r\n\r\nHowever 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."}}
{"actor":{"display_login":"di"}}