Change SortBy.INSTALLS to INSTALLED

This commit is contained in:
Michael McCaskill 2016-08-25 13:47:05 -04:00
parent d9cba6b3c4
commit 6abc879e23
5 changed files with 6 additions and 6 deletions

View File

@ -45,7 +45,7 @@ public class PluginsEndpoint {
@GET
public Plugins getMostInstalled(@DefaultValue("10") @QueryParam("limit") int limit) {
try {
return datastoreService.search(new SearchOptions(null, SortBy.INSTALLS, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), null, limit, 1));
return datastoreService.search(new SearchOptions(null, SortBy.INSTALLED, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), null, limit, 1));
} catch (ServiceException e) {
logger.error("Problem getting most installed", e);
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);

View File

@ -2,7 +2,7 @@ package io.jenkins.plugins.services;
public enum SortBy {
INSTALLS,
INSTALLED,
NAME,
RELEVANCE,
TITLE,

View File

@ -92,7 +92,7 @@ public class ElasticsearchDatastoreService implements DatastoreService {
requestBuilder.setQuery(queryBuilder);
if (searchOptions.getSortBy() != null) {
switch (searchOptions.getSortBy()) {
case INSTALLS:
case INSTALLED:
requestBuilder.addSort(SortBuilders.fieldSort("stats.currentInstalls").setNestedPath("stats").order(SortOrder.DESC));
break;
case NAME:

View File

@ -46,7 +46,7 @@ public class RestAppIntegrationTest extends JerseyTest {
final Plugins plugins = target("/plugins").queryParam("q", "git").queryParam("sort", "installs").request().get(Plugins.class);
Assert.assertNotNull("Search for 'git' null", plugins);
Assert.assertTrue("Should return multiple results", plugins.getTotal() > 1);
Assert.assertTrue("SortBy.INSTALLS not correct", plugins.getPlugins().get(0).getStats().getCurrentInstalls() > plugins.getPlugins().get(1).getStats().getCurrentInstalls());
Assert.assertTrue("SortBy.INSTALLED not correct", plugins.getPlugins().get(0).getStats().getCurrentInstalls() > plugins.getPlugins().get(1).getStats().getCurrentInstalls());
}
@Test

View File

@ -52,10 +52,10 @@ public class DatastoreServiceIntegrationTest {
@Test
public void testSearchSortByInstalls() {
final Plugins plugins = datastoreService.search(new SearchOptions("git", SortBy.INSTALLS, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), null, 50, 1));
final Plugins plugins = datastoreService.search(new SearchOptions("git", SortBy.INSTALLED, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), null, 50, 1));
Assert.assertNotNull("Search for 'git' sort by installs is null", plugins);
Assert.assertTrue("Should return multiple results", plugins.getTotal() > 1);
Assert.assertTrue("SortBy.INSTALLS not correct", plugins.getPlugins().get(0).getStats().getCurrentInstalls() > plugins.getPlugins().get(1).getStats().getCurrentInstalls());
Assert.assertTrue("SortBy.INSTALLED not correct", plugins.getPlugins().get(0).getStats().getCurrentInstalls() > plugins.getPlugins().get(1).getStats().getCurrentInstalls());
}
@Test