NuGet/NuGetGallery — pull request #462 by anglicangeek (2012-03-20 07:15:44+00:00)
Title: Curated feeds

I still need to do a more testing and self-code review on this (I'm sure there are still things to be fixed), but it's close enough to start a team review and to have the Test folks start banging on it. All of these changes are currently live on the preview server, so you can play with them there. Below is my (quick and dirty) documentation

_First, a short note on how the feature was composed._

I developed this feature using a different compositional approach in terms of abstractions, unit tests, and dependencies. Specifically, instead of big services, I used fine-grained, single-purpose command and query classes. I'm not trying to be all CQRS-y; I just find that it leads to tighter composition and tighter unit tests. You'll notice that I'm making heavy use of the testable object pattern in the unit tests. You'll also notice that I'm using service location (or dependency lookup, if you prefer) instead of dependency injection. I find this makes for tighter tests, at least with ASP.NET MVC. It also makes it easier to introduce new dependencies, which is more important when you're using fine-grained commands and queries instead of big services. Compare the unit tests for this feature to some of the others in the app and you'll see what I mean.

To be clear, this compositional approach is an experiment. It's easy to refactor it like the rest if we don't like it. But I *really* like it, and if others do too, I'd like to start using personal time to refactor the rest of the app to use this approach.

Now, on to documenting the feature.

## Creating a Curated Feed

There is no UI for creating a new curated feed. You must use /dbadmin, both to create the curated feed and to add users to its managers collection. This seems reasonable, since this isn't a user-facing feature, and we only expect to have two of them, at least for now.

## Automatic Package Curation

When a user verifies a new package they've uploaded, _and that package is the new latest, stable package version_, the package is automatically curated for WebMatrix. The curation rules are:

* If it has the `aspnetwebpages` tag, it is automatically included in the WebMatrix curated feed
* If it doesn't have the tag, but it also doesn't have any .ps1 or .t4 files, it is automatically included in the WebMatrix curated feed

_These rules might change after further discussion with the WebMatrix folks._

## Manual Package Curation

If you are a manager of a curated feed, your curated feeds will be listed in your account page (click on your username).

![My account with curated feeds](http://i.imgur.com/h8LHV.png)

### The Curated Feed Page

Clicking on one of your curated feeds on the account page will take you to the curated feed page. This page lists the managers of the curated feed, all of the included packages, and all of the excluded packages (more on that below).

![The curated feed page](http://i.imgur.com/ZXK2V.png)

You'll notice that there is no paging on the list of included packages. This is something we might consider adding down the road, but the page loads quickly enough even with 5000 packages in the list, and it's easy to search for what you want. Also, this page doesn't really have any information that you'd want to browse.

### Manually Including a Package in the Feed

To manually include a package in the curated feed, click the Include Package link.

![The include package link](http://i.imgur.com/ab5LS.png)

This will take you to the Include Package form. Enter the package ID you want to include, and optionally a note (I'm not yet displaying the note anywhere; in fact, I really only added the note to make dynamic data happy, and I'll probably remove it once I figure out the "right way" to handle an entity with no string property).

![The include package form](http://i.imgur.com/PQg2t.png)

### Excluding an automatically-curated package

Sometimes a package will meet the automatic-curation rules but still should be excluded from the feed. In this case, just click the Exclude link next to an automatically-added package.

![The exclude link](http://i.imgur.com/dJQgX.png)

### Removing a manually-curated package

To remove a manually-curated package, click the Remove link next to an automatically-added package.

![The remove link](http://i.imgur.com/BlV8T.png)

## The Curated Feed Service URL

The URL for a curated feed is: /api/v2/curated-feeds/{name}, e.g. http://preview.nuget.org/api/v2/curated-feeds/anglicangeek/. The idea is that you can use this URL anywhere you would use the main feed service URL.

## Batch Curation for Existing Packages

I *have not* yet run a batch curation ops task for the existing packages, but the task uses the same curation class that package verification uses, so starting testing there will be very helpful, and by the end of the week we'll run the batch task on preview.

## Test Concerns

We are doing some evil things with the data service to get this to work, like rewriting the URL to push in a query string parameter with the curated feed name, and pulling it from the HTTP context in the data service. The most critical exploratory testing, then, should be to make sure the curated feeds behave just like the main feed. This means exploring not only VS, PowerShell, and nuget.exe, but also direct OData and NPE (and any other clients we think are good test subjects).

Performance of the curated feed service is another important area to test.

Aside form exploring the feed service, normal test activities are appropriate.