Merge remote-tracking branch 'upstream/skynet' into SEARCH-438

# Conflicts:
#	js/search/search.js
This commit is contained in:
Keerthi Niranjan
2017-11-23 21:48:03 +05:30
11 changed files with 175 additions and 73 deletions

View File

@@ -66,6 +66,10 @@ class Search {
searchConfig.REAL_TIME_INDEXING_TIME, this.realTimeIndexing.bind(this));
}
/**
* Decrypting the existing user .enc file
* and initialing the library
*/
decryptAndInit() {
this.crypto.decryption().then(() => {
console.timeEnd('Decrypting');
@@ -304,18 +308,21 @@ class Search {
return;
}
let sd = new Date().getTime() - searchConfig.SEARCH_PERIOD_SUBTRACTOR;
let sd_time = searchConfig.MINIMUM_DATE;
if (startDate && startDate !== "" && typeof startDate === 'object') {
sd_time = new Date(startDate).getTime();
if (sd_time >= sd) {
sd_time = sd;
let searchPeriod = new Date().getTime() - SEARCH_PERIOD_SUBTRACTOR;
let startDateTime = searchPeriod;
if (startDate) {
startDateTime = new Date(parseInt(startDate, 10)).getTime();
if (!startDateTime || startDateTime < searchPeriod) {
startDateTime = searchPeriod;
}
}
let ed_time = searchConfig.MAXIMUM_DATE;
if (endDate && endDate !== "" && typeof endDate === 'object') {
ed_time = new Date(endDate).getTime();
let endDateTime = searchConfig.MAXIMUM_DATE;
if (endDate) {
let eTime = new Date(parseInt(endDate, 10)).getTime();
if (eTime) {
endDateTime = eTime;
}
}
if (!_limit && _limit === "" && typeof _limit !== 'number' && Math.round(_limit) !== _limit) {
@@ -330,7 +337,7 @@ class Search {
_sortOrder = searchConfig.SORT_BY_SCORE;
}
const returnedResult = libSymphonySearch.symSESearch(this.indexFolderName, this.realTimeIndex, q, sd_time.toString(), ed_time.toString(), _offset, _limit, _sortOrder);
const returnedResult = libSymphonySearch.symSESearch(this.indexFolderName, this.realTimeIndex, q, startDateTime.toString(), endDateTime.toString(), _offset, _limit, _sortOrder);
try {
let ret = returnedResult.readCString();
resolve(JSON.parse(ret));