{"action":"created","comment":{"url":"https://api.github.com/repos/NuGet/NuGetGallery/pulls/comments/37071514","id":37071514,"diff_hunk":"@@ -0,0 +1,230 @@\n+﻿// Copyright (c) .NET Foundation. All rights reserved.\n+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\n+\n+using System;\n+using System.Collections.Generic;\n+using System.Linq;\n+using System.Net;\n+using System.Net.Http;\n+using System.Threading.Tasks;\n+using System.Web.Http;\n+using System.Web.Http.OData;\n+using System.Web.Http.OData.Query;\n+using NuGetGallery.Configuration;\n+using NuGetGallery.OData;\n+using NuGetGallery.OData.QueryInterceptors;\n+using QueryInterceptor;\n+using WebApi.OutputCache.V2;\n+\n+// ReSharper disable once CheckNamespace\n+namespace NuGetGallery.Controllers\n+{\n+    public class ODataV2CuratedFeedController \n+        : NuGetODataController\n+    {\n+        private const int MaxPageSize = 40;\n+\n+        private readonly IEntitiesContext _entities;\n+        private readonly ConfigurationService _configurationService;\n+        private readonly ISearchService _searchService;\n+        private readonly ICuratedFeedService _curatedFeedService;\n+\n+        private static readonly ODataQuerySettings SearchQuerySettings = new ODataQuerySettings \n+        { \n+             HandleNullPropagation = HandleNullPropagationOption.False,\n+             EnsureStableOrdering = true\n+        };\n+\n+        public ODataV2CuratedFeedController(\n+            IEntitiesContext entities,\n+            ConfigurationService configurationService,\n+            ISearchService searchService,\n+            ICuratedFeedService curatedFeedService)\n+            : base(configurationService)\n+        {\n+            _entities = entities;\n+            _configurationService = configurationService;\n+            _searchService = searchService;\n+            _curatedFeedService = curatedFeedService;\n+        }\n+\n+        // /api/v2/curated-feed/curatedFeedName/Packages\n+        [HttpGet]\n+        [HttpPost]\n+        [EnableQuery(PageSize = MaxPageSize, HandleNullPropagation = HandleNullPropagationOption.False, EnsureStableOrdering = true, AllowedQueryOptions = AllowedQueryOptions.All)]\n+        public IQueryable<V2FeedPackage> Get(string curatedFeedName)\n+        {\n+            if (!_entities.CuratedFeeds.Any(cf => cf.Name == curatedFeedName))\n+            {\n+                throw new HttpResponseException(HttpStatusCode.NotFound);\n+            }\n+\n+            var packages = _curatedFeedService.GetPackages(curatedFeedName)\n+                .ToV2FeedPackageQuery(_configurationService.GetSiteRoot(UseHttps()), _configurationService.Features.FriendlyLicenses)\n+                .InterceptWith(new NormalizeVersionInterceptor());\n+\n+            return packages;\n+        }\n+\n+        // /api/v2/curated-feed/curatedFeedName/Packages/$count\n+        [HttpGet]\n+        public HttpResponseMessage GetCount(string curatedFeedName, ODataQueryOptions<V2FeedPackage> options)\n+        {\n+            var queryResults = (IQueryable<V2FeedPackage>)options.ApplyTo(Get(curatedFeedName));\n+            var count = queryResults.Count();\n+\n+            return CountResult(count);\n+        }\n+\n+        // /api/v2/curated-feed/curatedFeedName/Packages(Id=,Version=)\n+        [HttpGet]\n+        [CacheOutput(ServerTimeSpan = NuGetODataConfig.GetByIdAndVersionCacheTimeInSeconds)]\n+        [EnableQuery(PageSize = MaxPageSize, HandleNullPropagation = HandleNullPropagationOption.False, EnsureStableOrdering = true, AllowedQueryOptions = AllowedQueryOptions.All)]\n+        public async Task<IHttpActionResult> Get(string curatedFeedName, string id, string version)\n+        {\n+            return await GetCore(curatedFeedName, id, version);\n+        }\n+\n+        // /api/v2/curated-feed/curatedFeedName/FindPackagesById()?id=\n+        [HttpGet]\n+        [HttpPost]\n+        [CacheOutput(ServerTimeSpan = NuGetODataConfig.GetByIdAndVersionCacheTimeInSeconds)]\n+        [EnableQuery(PageSize = MaxPageSize, HandleNullPropagation = HandleNullPropagationOption.False, EnsureStableOrdering = true, AllowedQueryOptions = AllowedQueryOptions.All)]\n+        public async Task<IHttpActionResult> FindPackagesById(string curatedFeedName, [FromODataUri]string id)\n+        {\n+            return await GetCore(curatedFeedName, id, null);\n+        }\n+\n+        private async Task<IHttpActionResult> GetCore(string curatedFeedName, string id, string version)\n+        {\n+            if (!_entities.CuratedFeeds.Any(cf => cf.Name == curatedFeedName))\n+            {\n+                throw new HttpResponseException(HttpStatusCode.NotFound);","path":"src/NuGetGallery/Controllers/ODataV2CuratedFeedController.cs","position":null,"original_position":102,"commit_id":"7fc679d2671cedce66e8f7c3a3afbce9179129d4","original_commit_id":"6d724fd79487a854164c53ae2cf72874fec25d63","user":{"login":"maartenba","id":485230,"avatar_url":"https://avatars.githubusercontent.com/u/485230?v=3","gravatar_id":"","url":"https://api.github.com/users/maartenba","html_url":"https://github.com/maartenba","followers_url":"https://api.github.com/users/maartenba/followers","following_url":"https://api.github.com/users/maartenba/following{/other_user}","gists_url":"https://api.github.com/users/maartenba/gists{/gist_id}","starred_url":"https://api.github.com/users/maartenba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maartenba/subscriptions","organizations_url":"https://api.github.com/users/maartenba/orgs","repos_url":"https://api.github.com/users/maartenba/repos","events_url":"https://api.github.com/users/maartenba/events{/privacy}","received_events_url":"https://api.github.com/users/maartenba/received_events","type":"User","site_admin":false},"body":"Updated.","created_at":"2015-08-14T12:29:28Z","updated_at":"2015-08-14T12:29:28Z","html_url":"https://github.com/NuGet/NuGetGallery/pull/2583#discussion_r37071514","pull_request_url":"https://api.github.com/repos/NuGet/NuGetGallery/pulls/2583","_links":{"self":{"href":"https://api.github.com/repos/NuGet/NuGetGallery/pulls/comments/37071514"},"html":{"href":"https://github.com/NuGet/NuGetGallery/pull/2583#discussion_r37071514"},"pull_request":{"href":"https://api.github.com/repos/NuGet/NuGetGallery/pulls/2583"}}},"pull_request":{"url":"https://api.github.com/repos/NuGet/NuGetGallery/pulls/2583","id":39813428,"html_url":"https://github.com/NuGet/NuGetGallery/pull/2583","diff_url":"https://github.com/NuGet/NuGetGallery/pull/2583.diff","patch_url":"https://github.com/NuGet/NuGetGallery/pull/2583.patch","issue_url":"https://api.github.com/repos/NuGet/NuGetGallery/issues/2583","number":2583,"state":"open","locked":false,"title":"Convert from WCF OData to Web API OData","user":{"login":"maartenba","id":485230,"avatar_url":"https://avatars.githubusercontent.com/u/485230?v=3","gravatar_id":"","url":"https://api.github.com/users/maartenba","html_url":"https://github.com/maartenba","followers_url":"https://api.github.com/users/maartenba/followers","following_url":"https://api.github.com/users/maartenba/following{/other_user}","gists_url":"https://api.github.com/users/maartenba/gists{/gist_id}","starred_url":"https://api.github.com/users/maartenba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maartenba/subscriptions","organizations_url":"https://api.github.com/users/maartenba/orgs","repos_url":"https://api.github.com/users/maartenba/repos","events_url":"https://api.github.com/users/maartenba/events{/privacy}","received_events_url":"https://api.github.com/users/maartenba/received_events","type":"User","site_admin":false},"body":"This PR fixes #2557.\r\n\r\n* V1, V2 and V2 curated feeds converted from WCF OData to Web API OData\r\n* WCF OData feeds removed\r\n* Caching on common search queries\r\n* Batching\r\n\r\n@xavierdecoster @yishaigalatzer @bhuvak @johnataylor Feel free to checkout this branch and perform some testing on the OData endpoints. Any bug / issue you find is very welcome!","created_at":"2015-07-13T13:50:58Z","updated_at":"2015-08-14T12:29:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b8d973e5e227d2047dbca7fcae42b68f50ae049c","assignee":{"login":"maartenba","id":485230,"avatar_url":"https://avatars.githubusercontent.com/u/485230?v=3","gravatar_id":"","url":"https://api.github.com/users/maartenba","html_url":"https://github.com/maartenba","followers_url":"https://api.github.com/users/maartenba/followers","following_url":"https://api.github.com/users/maartenba/following{/other_user}","gists_url":"https://api.github.com/users/maartenba/gists{/gist_id}","starred_url":"https://api.github.com/users/maartenba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maartenba/subscriptions","organizations_url":"https://api.github.com/users/maartenba/orgs","repos_url":"https://api.github.com/users/maartenba/repos","events_url":"https://api.github.com/users/maartenba/events{/privacy}","received_events_url":"https://api.github.com/users/maartenba/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/NuGet/NuGetGallery/milestones/80","html_url":"https://github.com/NuGet/NuGetGallery/milestones/S4","labels_url":"https://api.github.com/repos/NuGet/NuGetGallery/milestones/80/labels","id":1204862,"number":80,"title":"S4","description":null,"creator":{"login":"maartenba","id":485230,"avatar_url":"https://avatars.githubusercontent.com/u/485230?v=3","gravatar_id":"","url":"https://api.github.com/users/maartenba","html_url":"https://github.com/maartenba","followers_url":"https://api.github.com/users/maartenba/followers","following_url":"https://api.github.com/users/maartenba/following{/other_user}","gists_url":"https://api.github.com/users/maartenba/gists{/gist_id}","starred_url":"https://api.github.com/users/maartenba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maartenba/subscriptions","organizations_url":"https://api.github.com/users/maartenba/orgs","repos_url":"https://api.github.com/users/maartenba/repos","events_url":"https://api.github.com/users/maartenba/events{/privacy}","received_events_url":"https://api.github.com/users/maartenba/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":8,"state":"open","created_at":"2015-07-13T10:27:08Z","updated_at":"2015-08-10T12:42:27Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/NuGet/NuGetGallery/pulls/2583/commits","review_comments_url":"https://api.github.com/repos/NuGet/NuGetGallery/pulls/2583/comments","review_comment_url":"https://api.github.com/repos/NuGet/NuGetGallery/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NuGet/NuGetGallery/issues/2583/comments","statuses_url":"https://api.github.com/repos/NuGet/NuGetGallery/statuses/7fc679d2671cedce66e8f7c3a3afbce9179129d4","head":{"label":"NuGet:issue-2557","ref":"issue-2557","sha":"7fc679d2671cedce66e8f7c3a3afbce9179129d4","user":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"repo":{"id":2180736,"name":"NuGetGallery","full_name":"NuGet/NuGetGallery","owner":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NuGet/NuGetGallery","description":"The NuGet Gallery","fork":false,"url":"https://api.github.com/repos/NuGet/NuGetGallery","forks_url":"https://api.github.com/repos/NuGet/NuGetGallery/forks","keys_url":"https://api.github.com/repos/NuGet/NuGetGallery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NuGet/NuGetGallery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NuGet/NuGetGallery/teams","hooks_url":"https://api.github.com/repos/NuGet/NuGetGallery/hooks","issue_events_url":"https://api.github.com/repos/NuGet/NuGetGallery/issues/events{/number}","events_url":"https://api.github.com/repos/NuGet/NuGetGallery/events","assignees_url":"https://api.github.com/repos/NuGet/NuGetGallery/assignees{/user}","branches_url":"https://api.github.com/repos/NuGet/NuGetGallery/branches{/branch}","tags_url":"https://api.github.com/repos/NuGet/NuGetGallery/tags","blobs_url":"https://api.github.com/repos/NuGet/NuGetGallery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NuGet/NuGetGallery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NuGet/NuGetGallery/git/refs{/sha}","trees_url":"https://api.github.com/repos/NuGet/NuGetGallery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NuGet/NuGetGallery/statuses/{sha}","languages_url":"https://api.github.com/repos/NuGet/NuGetGallery/languages","stargazers_url":"https://api.github.com/repos/NuGet/NuGetGallery/stargazers","contributors_url":"https://api.github.com/repos/NuGet/NuGetGallery/contributors","subscribers_url":"https://api.github.com/repos/NuGet/NuGetGallery/subscribers","subscription_url":"https://api.github.com/repos/NuGet/NuGetGallery/subscription","commits_url":"https://api.github.com/repos/NuGet/NuGetGallery/commits{/sha}","git_commits_url":"https://api.github.com/repos/NuGet/NuGetGallery/git/commits{/sha}","comments_url":"https://api.github.com/repos/NuGet/NuGetGallery/comments{/number}","issue_comment_url":"https://api.github.com/repos/NuGet/NuGetGallery/issues/comments{/number}","contents_url":"https://api.github.com/repos/NuGet/NuGetGallery/contents/{+path}","compare_url":"https://api.github.com/repos/NuGet/NuGetGallery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NuGet/NuGetGallery/merges","archive_url":"https://api.github.com/repos/NuGet/NuGetGallery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NuGet/NuGetGallery/downloads","issues_url":"https://api.github.com/repos/NuGet/NuGetGallery/issues{/number}","pulls_url":"https://api.github.com/repos/NuGet/NuGetGallery/pulls{/number}","milestones_url":"https://api.github.com/repos/NuGet/NuGetGallery/milestones{/number}","notifications_url":"https://api.github.com/repos/NuGet/NuGetGallery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NuGet/NuGetGallery/labels{/name}","releases_url":"https://api.github.com/repos/NuGet/NuGetGallery/releases{/id}","created_at":"2011-08-09T17:57:32Z","updated_at":"2015-08-02T04:34:29Z","pushed_at":"2015-08-14T12:27:04Z","git_url":"git://github.com/NuGet/NuGetGallery.git","ssh_url":"git@github.com:NuGet/NuGetGallery.git","clone_url":"https://github.com/NuGet/NuGetGallery.git","svn_url":"https://github.com/NuGet/NuGetGallery","homepage":"http://www.nuget.org","size":76862,"stargazers_count":605,"watchers_count":605,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":350,"mirror_url":null,"open_issues_count":206,"forks":350,"open_issues":206,"watchers":605,"default_branch":"master"}},"base":{"label":"NuGet:dev","ref":"dev","sha":"4efa7e6578385ef582e8c695a9ab8c9950869a0d","user":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"repo":{"id":2180736,"name":"NuGetGallery","full_name":"NuGet/NuGetGallery","owner":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NuGet/NuGetGallery","description":"The NuGet Gallery","fork":false,"url":"https://api.github.com/repos/NuGet/NuGetGallery","forks_url":"https://api.github.com/repos/NuGet/NuGetGallery/forks","keys_url":"https://api.github.com/repos/NuGet/NuGetGallery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NuGet/NuGetGallery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NuGet/NuGetGallery/teams","hooks_url":"https://api.github.com/repos/NuGet/NuGetGallery/hooks","issue_events_url":"https://api.github.com/repos/NuGet/NuGetGallery/issues/events{/number}","events_url":"https://api.github.com/repos/NuGet/NuGetGallery/events","assignees_url":"https://api.github.com/repos/NuGet/NuGetGallery/assignees{/user}","branches_url":"https://api.github.com/repos/NuGet/NuGetGallery/branches{/branch}","tags_url":"https://api.github.com/repos/NuGet/NuGetGallery/tags","blobs_url":"https://api.github.com/repos/NuGet/NuGetGallery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NuGet/NuGetGallery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NuGet/NuGetGallery/git/refs{/sha}","trees_url":"https://api.github.com/repos/NuGet/NuGetGallery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NuGet/NuGetGallery/statuses/{sha}","languages_url":"https://api.github.com/repos/NuGet/NuGetGallery/languages","stargazers_url":"https://api.github.com/repos/NuGet/NuGetGallery/stargazers","contributors_url":"https://api.github.com/repos/NuGet/NuGetGallery/contributors","subscribers_url":"https://api.github.com/repos/NuGet/NuGetGallery/subscribers","subscription_url":"https://api.github.com/repos/NuGet/NuGetGallery/subscription","commits_url":"https://api.github.com/repos/NuGet/NuGetGallery/commits{/sha}","git_commits_url":"https://api.github.com/repos/NuGet/NuGetGallery/git/commits{/sha}","comments_url":"https://api.github.com/repos/NuGet/NuGetGallery/comments{/number}","issue_comment_url":"https://api.github.com/repos/NuGet/NuGetGallery/issues/comments{/number}","contents_url":"https://api.github.com/repos/NuGet/NuGetGallery/contents/{+path}","compare_url":"https://api.github.com/repos/NuGet/NuGetGallery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NuGet/NuGetGallery/merges","archive_url":"https://api.github.com/repos/NuGet/NuGetGallery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NuGet/NuGetGallery/downloads","issues_url":"https://api.github.com/repos/NuGet/NuGetGallery/issues{/number}","pulls_url":"https://api.github.com/repos/NuGet/NuGetGallery/pulls{/number}","milestones_url":"https://api.github.com/repos/NuGet/NuGetGallery/milestones{/number}","notifications_url":"https://api.github.com/repos/NuGet/NuGetGallery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NuGet/NuGetGallery/labels{/name}","releases_url":"https://api.github.com/repos/NuGet/NuGetGallery/releases{/id}","created_at":"2011-08-09T17:57:32Z","updated_at":"2015-08-02T04:34:29Z","pushed_at":"2015-08-14T12:27:04Z","git_url":"git://github.com/NuGet/NuGetGallery.git","ssh_url":"git@github.com:NuGet/NuGetGallery.git","clone_url":"https://github.com/NuGet/NuGetGallery.git","svn_url":"https://github.com/NuGet/NuGetGallery","homepage":"http://www.nuget.org","size":76862,"stargazers_count":605,"watchers_count":605,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":350,"mirror_url":null,"open_issues_count":206,"forks":350,"open_issues":206,"watchers":605,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NuGet/NuGetGallery/pulls/2583"},"html":{"href":"https://github.com/NuGet/NuGetGallery/pull/2583"},"issue":{"href":"https://api.github.com/repos/NuGet/NuGetGallery/issues/2583"},"comments":{"href":"https://api.github.com/repos/NuGet/NuGetGallery/issues/2583/comments"},"review_comments":{"href":"https://api.github.com/repos/NuGet/NuGetGallery/pulls/2583/comments"},"review_comment":{"href":"https://api.github.com/repos/NuGet/NuGetGallery/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NuGet/NuGetGallery/pulls/2583/commits"},"statuses":{"href":"https://api.github.com/repos/NuGet/NuGetGallery/statuses/7fc679d2671cedce66e8f7c3a3afbce9179129d4"}}}}