Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limit IP search to 30 days #220

Open
wants to merge 1 commit into
base: 3.2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -126,9 +127,16 @@ public GeneralSearchStats generalSearchStats(@RequestParam(SERVICE_PARAM) String
MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE})
@ResponseBody
public List<IpStats> 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<Object[]> resultList = query.getResultList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ <h2 data-translate="">cswStatistics</h2>
</div>
</div>

<!--<div class="col-lg-12">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading" data-translate="">searchIp</div>
<div class="panel-body">
Expand All @@ -109,7 +109,7 @@ <h2 data-translate="">cswStatistics</h2>
</button>
</div>
</div>
</div>-->
</div>

<div class="col-lg-12">
<div class="panel panel-default">
Expand Down