Skip to content

Commit

Permalink
Hotfix: Revert "Fix SemVerLevel propagation in Odata Next links. (#5582
Browse files Browse the repository at this point in the history
…)" (#5623)

This reverts commit eeb6929.
  • Loading branch information
Scott Bommarito authored Mar 15, 2018
1 parent 75aabfa commit 2425677
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 34 deletions.
5 changes: 2 additions & 3 deletions src/NuGetGallery/Controllers/ODataV2CuratedFeedController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private async Task<IHttpActionResult> GetCore(
.ToV2FeedPackageQuery(GetSiteRoot(), _configurationService.Features.FriendlyLicenses, semVerLevelKey);

return QueryResult(options, pagedQueryable, MaxPageSize, totalHits, (o, s, resultCount) =>
SearchAdaptor.GetNextLink(Request.RequestUri, resultCount, new { id }, o, s, semVerLevelKey));
SearchAdaptor.GetNextLink(Request.RequestUri, resultCount, new { id }, o, s));
}
}
catch (Exception ex)
Expand Down Expand Up @@ -299,8 +299,7 @@ public async Task<IHttpActionResult> Search(
resultCount,
new { searchTerm, targetFramework, includePrerelease },
o,
s,
semVerLevelKey);
s);
}
return null;
});
Expand Down
6 changes: 3 additions & 3 deletions src/NuGetGallery/Controllers/ODataV2FeedController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public async Task<IHttpActionResult> Get(
semVerLevelKey);

return QueryResult(options, pagedQueryable, MaxPageSize, totalHits, (o, s, resultCount) =>
SearchAdaptor.GetNextLink(Request.RequestUri, resultCount, null, o, s, semVerLevelKey));
SearchAdaptor.GetNextLink(Request.RequestUri, resultCount, null, o, s));
}
}
}
Expand Down Expand Up @@ -251,7 +251,7 @@ private async Task<IHttpActionResult> GetCore(
semVerLevelKey);

return QueryResult(options, pagedQueryable, MaxPageSize, totalHits, (o, s, resultCount) =>
SearchAdaptor.GetNextLink(Request.RequestUri, resultCount, new { id }, o, s, semVerLevelKey));
SearchAdaptor.GetNextLink(Request.RequestUri, resultCount, new { id }, o, s));
}
}
catch (Exception ex)
Expand Down Expand Up @@ -358,7 +358,7 @@ public async Task<IHttpActionResult> Search(
// Strip it of for backward compatibility.
if (o.Top == null || (resultCount.HasValue && o.Top.Value >= resultCount.Value))
{
return SearchAdaptor.GetNextLink(Request.RequestUri, resultCount, new { searchTerm, targetFramework, includePrerelease }, o, s, semVerLevelKey);
return SearchAdaptor.GetNextLink(Request.RequestUri, resultCount, new { searchTerm, targetFramework, includePrerelease }, o, s);
}
return null;
});
Expand Down
12 changes: 1 addition & 11 deletions src/NuGetGallery/OData/SearchService/SearchAdaptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ private static bool TryReadSearchFilter(bool allVersionsInIndex, string url, boo
return true;
}

public static Uri GetNextLink(Uri currentRequestUri, long? totalResultCount, object queryParameters, ODataQueryOptions options, ODataQuerySettings settings, int? semVerLevelKey = null)
public static Uri GetNextLink(Uri currentRequestUri, long? totalResultCount, object queryParameters, ODataQueryOptions options, ODataQuerySettings settings)
{
if (!totalResultCount.HasValue || totalResultCount.Value <= MaxPageSize || totalResultCount.Value == 0)
{
Expand Down Expand Up @@ -374,16 +374,6 @@ public static Uri GetNextLink(Uri currentRequestUri, long? totalResultCount, obj
queryBuilder.Append("&");
}

if (semVerLevelKey != null)
{
if(semVerLevelKey == SemVerLevelKey.SemVer2)
{
queryBuilder.Append("semVerLevel=");
queryBuilder.Append(SemVerLevelKey.SemVerLevel2);
queryBuilder.Append("&");
}
}

var queryString = queryBuilder.ToString().TrimEnd('&');

var builder = new UriBuilder(currentRequestUri);
Expand Down
17 changes: 0 additions & 17 deletions tests/NuGetGallery.Facts/Services/SearchAdaptorFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,23 +133,6 @@ public void GeneratesNextLinkForComplexUrl()
// Assert
Assert.Equal(new Uri("https://localhost:8081/api/v2/Search()?searchTerm='foo'&$orderby=Id&$skip=200&$top=1000"), nextLink);
}

[Fact]
public void GeneratesNextLinkForComplexUrlWithSemVerLevel2()
{
// Arrange
var requestUri = new Uri("https://localhost:8081/api/v2/Search()?searchTerm='foo'&$orderby=Id&$skip=100&$top=1000&semVerLevel=2.0.0");
var resultCount = 2000; // our result set contains 2000 elements

// Act
var nextLink = SearchAdaptor.GetNextLink(requestUri, resultCount, new { searchTerm = "foo" },
GetODataQueryOptionsForTest(requestUri),
GetODataQuerySettingsForTest(),
SemVerLevelKey.SemVer2);

// Assert
Assert.Equal(new Uri("https://localhost:8081/api/v2/Search()?searchTerm='foo'&$orderby=Id&$skip=200&$top=1000&semVerLevel=2.0.0"), nextLink);
}
}
}
}

0 comments on commit 2425677

Please sign in to comment.