Rename stats.lifetime to stats.currentInstalls

I thought the last entry in the stats.installations represented a
'lifetime' count of the number of installs, which therefore never went
down. This is incorrect as it represents the current number of installs.
This commit is contained in:
Michael McCaskill 2016-08-23 10:38:59 -04:00
parent 2524980735
commit e8d4cae40c
8 changed files with 19 additions and 19 deletions

View File

@ -221,7 +221,7 @@ Sample Response
},
...
],
"lifetime": 89232,
"currentInstalls": 89232,
"trend": 2990
},
"title": "Jenkins Git plugin",
@ -325,7 +325,7 @@ Sample Response
},
...
],
"lifetime": 89232,
"currentInstalls": 89232,
"trend": 2990
},
"title": "Jenkins Git plugin",
@ -427,7 +427,7 @@ Sample Response
},
...
],
"lifetime": 89232,
"currentInstalls": 89232,
"trend": 2990
},
"title": "Jenkins Git plugin",
@ -529,7 +529,7 @@ Sample Response
},
...
],
"lifetime": 89232,
"currentInstalls": 89232,
"trend": 2990
},
"title": "Jenkins Git plugin",
@ -631,7 +631,7 @@ Sample Response
},
...
],
"lifetime": 89232,
"currentInstalls": 89232,
"trend": 2990
},
"title": "Jenkins Git plugin",

View File

@ -195,7 +195,7 @@ public class GeneratePluginData {
installationsPercentagePerVersion.getDouble(version)
)
).sorted(Comparator.comparing(InstallationPercentageVersion::getVersion)).collect(Collectors.toList()));
stats.setLifetime(!stats.getInstallations().isEmpty() ? stats.getInstallations().get(stats.getInstallations().size()-1).getTotal() : 0);
stats.setCurrentInstalls(!stats.getInstallations().isEmpty() ? stats.getInstallations().get(stats.getInstallations().size()-1).getTotal() : 0);
if (stats.getInstallations().size() > 1) {
final int size = stats.getInstallations().size();
final long trend = stats.getInstallations().get(size-1).getTotal() - stats.getInstallations().get(size-2).getTotal();

View File

@ -20,8 +20,8 @@ public class Stats {
@JsonProperty("installationsPercentagePerVersion")
private List<InstallationPercentageVersion> installationsPercentagePerVersion;
@JsonProperty("lifetime")
private long lifetime;
@JsonProperty("currentInstalls")
private long currentInstalls;
@JsonProperty("trend")
private long trend;
@ -29,12 +29,12 @@ public class Stats {
public Stats() {
}
public Stats(List<Installation> installations, List<InstallationPercentage> installationsPercentage, List<InstallationVersion> installationsPerVersion, List<InstallationPercentageVersion> installationsPercentagePerVersion, long lifetime, long trend) {
public Stats(List<Installation> installations, List<InstallationPercentage> installationsPercentage, List<InstallationVersion> installationsPerVersion, List<InstallationPercentageVersion> installationsPercentagePerVersion, long currentInstalls, long trend) {
this.installations = installations;
this.installationsPercentage = installationsPercentage;
this.installationsPerVersion = installationsPerVersion;
this.installationsPercentagePerVersion = installationsPercentagePerVersion;
this.lifetime = lifetime;
this.currentInstalls = currentInstalls;
this.trend = trend;
}
@ -70,12 +70,12 @@ public class Stats {
this.installationsPercentagePerVersion = installationsPercentagePerVersion;
}
public long getLifetime() {
return lifetime;
public long getCurrentInstalls() {
return currentInstalls;
}
public void setLifetime(long lifetime) {
this.lifetime = lifetime;
public void setCurrentInstalls(long currentInstalls) {
this.currentInstalls = currentInstalls;
}
public long getTrend() {

View File

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

View File

@ -143,7 +143,7 @@
}
}
},
"lifetime" : {
"currentInstalls" : {
"type" : "long"
},
"trend" : {

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().getLifetime() > plugins.getPlugins().get(1).getStats().getLifetime());
Assert.assertTrue("SortBy.INSTALLS not correct", plugins.getPlugins().get(0).getStats().getCurrentInstalls() > plugins.getPlugins().get(1).getStats().getCurrentInstalls());
}
@Test
@ -166,7 +166,7 @@ public class RestAppIntegrationTest extends JerseyTest {
final Plugins plugins = target("/plugins/installed").request().get(Plugins.class);
Assert.assertNotNull("Most installed null", plugins);
Assert.assertTrue("Should return multiple results", plugins.getTotal() > 1);
Assert.assertTrue("Most installed order not correct", plugins.getPlugins().get(0).getStats().getLifetime() > plugins.getPlugins().get(1).getStats().getLifetime());
Assert.assertTrue("Most installed order not correct", plugins.getPlugins().get(0).getStats().getCurrentInstalls() > plugins.getPlugins().get(1).getStats().getCurrentInstalls());
Assert.assertEquals("Most installed limit doesn't match", plugins.getLimit(), plugins.getPlugins().size());
}

View File

@ -55,7 +55,7 @@ public class DatastoreServiceIntegrationTest {
final Plugins plugins = datastoreService.search(new SearchOptions("git", SortBy.INSTALLS, 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().getLifetime() > plugins.getPlugins().get(1).getStats().getLifetime());
Assert.assertTrue("SortBy.INSTALLS not correct", plugins.getPlugins().get(0).getStats().getCurrentInstalls() > plugins.getPlugins().get(1).getStats().getCurrentInstalls());
}
@Test