diff --git a/src/main/java/eu/dnetlib/repo/manager/controllers/DashboardController.java b/src/main/java/eu/dnetlib/repo/manager/controllers/DashboardController.java index a0c32cb..3fd6650 100644 --- a/src/main/java/eu/dnetlib/repo/manager/controllers/DashboardController.java +++ b/src/main/java/eu/dnetlib/repo/manager/controllers/DashboardController.java @@ -55,31 +55,21 @@ public class DashboardController { @PreAuthorize("hasAuthority('REGISTERED_USER')") public CollectionMonitorSummary getCollectionMonitorSummary( @PathVariable("repoId") String repoId, - @RequestParam(name = "size", required = false, defaultValue = "20") int size) throws JSONException { + @RequestParam(name = "size", required = false, defaultValue = "20") int summarySize) throws JSONException { - // Get the "aggregationInfo" for the first requested aggregations. - List aggregationInfoList = aggregationService.getRepositoryAggregations(repoId, 0, size); + List aggregationInfoList = aggregationService.getRepositoryAggregations(repoId); CollectionMonitorSummary collectionMonitorSummary = new CollectionMonitorSummary(); - collectionMonitorSummary.setAggregationInfo(aggregationInfoList); + // Set the "aggregationInfo" for the first requested aggregations, in order to create a "summary". + collectionMonitorSummary.setAggregationInfo(aggregationInfoList.subList(0, Math.min(summarySize, aggregationInfoList.size()))); - // Search for the last indexed version, from the beginning of the list. - - // TODO - WARNING! This is very slow, since each time it requests the next 50, it re-requests the whole list from the "/ds/aggregationhistory/" DSM-endpoint. - // inside "AggregationServiceImpl.getRepositoryAggregations()". Then it splits the list in a chunk of 50 and then iterate though it here.. - // Since we already request the whole list each time anyway, just take that use it here!! - - size = 0; - do { - aggregationInfoList = aggregationService.getRepositoryAggregations(repoId, size, size + 50); - for (AggregationInfo aggregationInfo : aggregationInfoList) { - if (aggregationInfo.isIndexedVersion()) { - collectionMonitorSummary.setLastIndexedVersion(aggregationInfo); - break; - } + // Search for the last indexed version and set the "collectionMonitorSummary". + for ( AggregationInfo aggregationInfo : aggregationInfoList ) { + if ( aggregationInfo.isIndexedVersion() ) { + collectionMonitorSummary.setLastIndexedVersion(aggregationInfo); + break; } - size += 50; - } while (aggregationInfoList.size() != 0 && collectionMonitorSummary.getLastIndexedVersion() == null); + } return collectionMonitorSummary; }