use of com.searchcode.app.service.TimeCodeSearcher in project searchcode-server by boyter.
the class TimeSearchRouteService method getTimeSearch.
public SearchResult getTimeSearch(Request request, Response response) {
Data data = Singleton.getData();
SearchcodeLib scl = Singleton.getSearchcodeLib(data);
TimeCodeSearcher cs = new TimeCodeSearcher();
CodeMatcher cm = new CodeMatcher(data);
response.header("Content-Encoding", "gzip");
if (request.queryParams().contains("q") == false || Values.EMPTYSTRING.equals(request.queryParams("q").trim())) {
return null;
}
String query = request.queryParams("q").trim();
int page = this.getPage(request);
String[] repos;
String[] langs;
String[] owners;
String[] year;
String[] yearmonth;
String[] yearmonthday;
String[] revisions;
String[] deleted;
String reposFilter = Values.EMPTYSTRING;
String langsFilter = Values.EMPTYSTRING;
String ownersFilter = Values.EMPTYSTRING;
String yearFilter = Values.EMPTYSTRING;
String yearMonthFilter = Values.EMPTYSTRING;
String yearMonthDayFilter = Values.EMPTYSTRING;
String revisionsFilter = Values.EMPTYSTRING;
String deletedFilter = Values.EMPTYSTRING;
if (request.queryParams().contains("repo")) {
repos = request.queryParamsValues("repo");
reposFilter = getRepos(repos, reposFilter);
}
if (request.queryParams().contains("lan")) {
langs = request.queryParamsValues("lan");
langsFilter = getLanguages(langs, langsFilter);
}
if (request.queryParams().contains("own")) {
owners = request.queryParamsValues("own");
ownersFilter = getOwners(owners, ownersFilter);
}
if (request.queryParams().contains("year")) {
year = request.queryParamsValues("year");
yearFilter = this.getYears(year, yearFilter);
}
if (request.queryParams().contains("ym")) {
yearmonth = request.queryParamsValues("ym");
yearMonthFilter = this.getYearMonths(yearmonth, yearMonthFilter);
}
if (request.queryParams().contains("ymd")) {
yearmonthday = request.queryParamsValues("ymd");
yearMonthDayFilter = this.getYearMonthDays(yearmonthday, yearMonthDayFilter);
}
if (request.queryParams().contains("rev")) {
revisions = request.queryParamsValues("rev");
revisionsFilter = this.getRevisions(revisions, revisionsFilter);
}
if (request.queryParams().contains("del")) {
deleted = request.queryParamsValues("del");
deletedFilter = this.getDeleted(deleted, deletedFilter);
}
// split the query escape it and and it together
String cleanQueryString = scl.formatQueryString(query);
SearchResult searchResult = cs.search(cleanQueryString + reposFilter + langsFilter + ownersFilter + yearFilter + yearMonthFilter + yearMonthDayFilter + revisionsFilter + deletedFilter, page);
searchResult.setCodeResultList(cm.formatResults(searchResult.getCodeResultList(), query, true));
searchResult.setQuery(query);
this.getAltQueries(scl, query, searchResult);
// Null out code as it isn't required and there is no point in bloating our ajax requests
for (CodeResult codeSearchResult : searchResult.getCodeResultList()) {
codeSearchResult.setCode(null);
}
return searchResult;
}
Aggregations