Skip to content
This repository
Browse code

Fixing an N+1 issue with Authors on the packages page.

  • Loading branch information...
commit cfb2db151bb7c9574e4d92c351ca8ce30afa7544 1 parent fbae50f
Jeff Handley authored August 23, 2012
9  Website/ViewModels/ListPackageItemViewModel.cs
@@ -6,11 +6,16 @@ namespace NuGetGallery
6 6
 {
7 7
     public class ListPackageItemViewModel : PackageViewModel
8 8
     {
9  
-        public ListPackageItemViewModel(Package package)
  9
+        public ListPackageItemViewModel(Package package, bool needAuthors = true)
10 10
             : base(package)
11 11
         {
12 12
             Tags = package.Tags != null ? package.Tags.Trim().Split(' ') : null;
13  
-            Authors = package.Authors;
  13
+
  14
+            if (needAuthors)
  15
+            {
  16
+                Authors = package.Authors;
  17
+            }
  18
+
14 19
             Owners = package.PackageRegistration.Owners;
15 20
         }
16 21
         public IEnumerable<PackageAuthor> Authors { get; set; }
2  Website/ViewModels/PackageListViewModel.cs
@@ -22,7 +22,7 @@ public class PackageListViewModel
22 22
                 items = packages.Skip(pageIndex * pageSize)
23 23
                                 .Take(pageSize)
24 24
                                 .ToList()
25  
-                                .Select(pv => new ListPackageItemViewModel(pv));
  25
+                                .Select(pv => new ListPackageItemViewModel(pv, needAuthors: false));
26 26
             }
27 27
             PageIndex = pageIndex;
28 28
             PageSize = pageSize;

0 notes on commit cfb2db1

Please sign in to comment.
Something went wrong with that request. Please try again.