diff --git a/services/src/main/java/org/fao/geonet/services/statistics/SearchStatistics.java b/services/src/main/java/org/fao/geonet/services/statistics/SearchStatistics.java index 85ffa7491c9..9e9b809688d 100644 --- a/services/src/main/java/org/fao/geonet/services/statistics/SearchStatistics.java +++ b/services/src/main/java/org/fao/geonet/services/statistics/SearchStatistics.java @@ -45,6 +45,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; +import java.util.Calendar; import java.util.List; import javax.annotation.Nonnull; @@ -126,9 +127,16 @@ public GeneralSearchStats generalSearchStats(@RequestParam(SERVICE_PARAM) String MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public List searchIpStats() { + int numberOfDaysAgo = -30; + Calendar cal = Calendar.getInstance(); + cal.add(Calendar.DATE, numberOfDaysAgo); + ISODate isoDate = new ISODate(cal.getTimeInMillis()); + final String queryString = - "select ipAddress, sum(hits) as sumhit from SearchRequest where autogenerated = FALSE group " + - "by ipAddress order by sumhit desc"; + "select ipAddress, sum(hits) as sumhit from SearchRequest " + + " where autogenerated = FALSE AND requestDate > '" + isoDate + "'" + + " group by " + + "ipAddress order by sumhit desc "; final Query query = entityManager.createQuery(queryString); @SuppressWarnings("unchecked") final List resultList = query.getResultList(); diff --git a/web-ui/src/main/resources/catalog/js/admin/DashboardSearchStatController.js b/web-ui/src/main/resources/catalog/js/admin/DashboardSearchStatController.js index d0de0afb95c..e6ad5978191 100644 --- a/web-ui/src/main/resources/catalog/js/admin/DashboardSearchStatController.js +++ b/web-ui/src/main/resources/catalog/js/admin/DashboardSearchStatController.js @@ -78,12 +78,12 @@ // TODO }); - /*$http.get('statistics-search-ip?_content_type=json') + $http.get('statistics-search-ip?_content_type=json') .success(function(data) { $scope.statistics.search.ip = data; }).error(function(data) { // TODO - });*/ + }); }; function getSearchStatByDate() { diff --git a/web-ui/src/main/resources/catalog/templates/admin/dashboard/statistics-search.html b/web-ui/src/main/resources/catalog/templates/admin/dashboard/statistics-search.html index 0f129306465..a7880c51648 100644 --- a/web-ui/src/main/resources/catalog/templates/admin/dashboard/statistics-search.html +++ b/web-ui/src/main/resources/catalog/templates/admin/dashboard/statistics-search.html @@ -94,7 +94,7 @@

cswStatistics

- +