Add year on usagestats
This commit is contained in:
parent
0358820465
commit
600965056b
|
@ -19,7 +19,7 @@ public interface StatsApi {
|
|||
@RequestMapping(value = "/getStatistics" , method = RequestMethod.GET,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
Map<String, String> getStatistics() throws JSONException;
|
||||
Map<String, Object> getStatistics() throws JSONException;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class StatsApiImpl implements StatsApi {
|
|||
|
||||
|
||||
@Override
|
||||
public Map<String, String> getStatistics() throws JSONException {
|
||||
public Map<String, Object> getStatistics() throws JSONException {
|
||||
|
||||
|
||||
String aggregators = getTotalByType("datasource",baseAddress+"/resources",
|
||||
|
@ -72,10 +72,10 @@ public class StatsApiImpl implements StatsApi {
|
|||
String publications = getTotalByType("other",baseAddress,"/publications/count");
|
||||
String datasets = getTotalByType("other",baseAddress,"/datasets/count");
|
||||
String software = getTotalByType("other",baseAddress,"/software/count");
|
||||
String usagestats = getUsageStatsTotal();
|
||||
JSONObject usagestats = getUsageStatsTotal();
|
||||
|
||||
|
||||
HashMap<String,String> stats = new HashMap<>();
|
||||
HashMap<String,Object> stats = new HashMap<>();
|
||||
stats.put("aggregators",aggregators);
|
||||
stats.put("dataRepositories",dataRepositories);
|
||||
stats.put("literature",literature);
|
||||
|
@ -84,7 +84,8 @@ public class StatsApiImpl implements StatsApi {
|
|||
stats.put("publications",publications);
|
||||
stats.put("datasets",datasets);
|
||||
stats.put("software",software);
|
||||
stats.put("usagestats",usagestats);
|
||||
|
||||
stats.put("usagestats",usagestats.toString());
|
||||
|
||||
|
||||
return stats;
|
||||
|
@ -109,7 +110,7 @@ public class StatsApiImpl implements StatsApi {
|
|||
|
||||
}
|
||||
|
||||
private String getUsageStatsTotal() throws JSONException {
|
||||
private JSONObject getUsageStatsTotal() throws JSONException {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(usagestatsBaseAddress + "/totals")
|
||||
.build().encode();
|
||||
|
@ -121,7 +122,12 @@ public class StatsApiImpl implements StatsApi {
|
|||
|
||||
Integer downloads = lastYear.getInt("downloads");
|
||||
Integer views = lastYear.getInt("views");
|
||||
String year = lastYear.getString("year");
|
||||
|
||||
return String.valueOf(downloads+views);
|
||||
JSONObject usagestats = new JSONObject();
|
||||
usagestats.put("number",String.valueOf(downloads+views));
|
||||
usagestats.put("year",year);
|
||||
|
||||
return usagestats;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue