Repository: pypi/warehouse

Issue:
Redesign release table
Right now we list the 'summary' of a release in the table:

![screenshot from 2018-03-09 07-04-08](https://user-images.githubusercontent.com/3323703/37194848-178b7464-2368-11e8-881c-29454067315f.png)

Feedback from user testing is that this value *so rarely* changes that it's not worth exposing here.

Instead we should:

1. Add information about what files are in the release
2. Try to expose the buttons directly (move them out of the dropdown if there is enough space)



Discussion:

Resolving patch:
diff --git a/warehouse/manage/views.py b/warehouse/manage/views.py
--- a/warehouse/manage/views.py
+++ b/warehouse/manage/views.py
@@ -22,7 +22,7 @@
 from pyramid.response import Response
 from pyramid.view import view_config, view_defaults
 from sqlalchemy import func
-from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import Load, joinedload
 from sqlalchemy.orm.exc import NoResultFound
 
 import warehouse.utils.otp as otp
@@ -815,7 +815,37 @@ def destroy_project_docs(project, request):
     permission="manage:project",
 )
 def manage_project_releases(project, request):
-    return {"project": project}
+    # Get the counts for all the files for this project, grouped by the
+    # release version and the package types
+    filecounts = (
+        request.db.query(Release.version, File.packagetype, func.count(File.id))
+        .options(Load(Release).load_only("version"))
+        .outerjoin(File)
+        .group_by(Release.id)
+        .group_by(File.packagetype)
+        .filter(Release.project == project)
+        .all()
+    )
+
+    # Turn rows like:
+    #   [('0.1', 'bdist_wheel', 2), ('0.1', 'sdist', 1)]
+    # into:
+    #   {
+    #       '0.1: {
+    #            'bdist_wheel': 2,
+    #            'sdist': 1,
+    #            'total': 3,
+    #       }
+    #   }
+
+    version_to_file_counts = {}
+    for version, packagetype, count in filecounts:
+        packagetype_to_count = version_to_file_counts.setdefault(version, {})
+        packagetype_to_count.setdefault("total", 0)
+        packagetype_to_count[packagetype] = count
+        packagetype_to_count["total"] += count
+
+    return {"project": project, "version_to_file_counts": version_to_file_counts}
 
 
 @view_defaults(


Test patch:
diff --git a/tests/unit/manage/test_views.py b/tests/unit/manage/test_views.py
--- a/tests/unit/manage/test_views.py
+++ b/tests/unit/manage/test_views.py
@@ -2151,11 +2151,21 @@ def test_destroy_project_docs(self, db_request):
 
 
 class TestManageProjectReleases:
-    def test_manage_project_releases(self):
-        request = pretend.stub()
-        project = pretend.stub()
+    def test_manage_project_releases(self, db_request):
+        project = ProjectFactory.create(name="foobar")
+        release = ReleaseFactory.create(project=project, version="1.0.0")
+        release_file = FileFactory.create(
+            release=release,
+            filename=f"foobar-{release.version}.tar.gz",
+            packagetype="sdist",
+        )
 
-        assert views.manage_project_releases(project, request) == {"project": project}
+        assert views.manage_project_releases(project, db_request) == {
+            "project": project,
+            "version_to_file_counts": {
+                release.version: {"total": 1, release_file.packagetype: 1}
+            },
+        }
 
 
 class TestManageProjectRelease: