From 38e27bba1f90710a3bfe7f2af267ff625ebeee31 Mon Sep 17 00:00:00 2001 From: Keerthi Niranjan Date: Tue, 21 Nov 2017 13:07:47 +0530 Subject: [PATCH 01/10] SEARCH-480 - Added date filter --- js/search/search.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/search/search.js b/js/search/search.js index 063cba96..1b0882f7 100644 --- a/js/search/search.js +++ b/js/search/search.js @@ -256,16 +256,16 @@ class Search { let sd = new Date().getTime() - SEARCH_PERIOD_SUBTRACTOR; let sd_time = MINIMUM_DATE; - if (startDate && startDate !== "" && typeof startDate === 'object') { - sd_time = new Date(startDate).getTime(); + if (startDate && startDate !== "") { + sd_time = new Date(parseInt(startDate, 10)).getTime(); if (sd_time >= sd) { sd_time = sd; } } let ed_time = MAXIMUM_DATE; - if (endDate && endDate !== "" && typeof endDate === 'object') { - ed_time = new Date(endDate).getTime(); + if (endDate && endDate !== "") { + ed_time = new Date(parseInt(endDate, 10)).getTime(); } if (!_limit && _limit === "" && typeof _limit !== 'number' && Math.round(_limit) !== _limit) { From 83d16928e0039c9c022eeb55cb2f5114db00c1a9 Mon Sep 17 00:00:00 2001 From: Keerthi Niranjan Date: Wed, 22 Nov 2017 15:35:59 +0530 Subject: [PATCH 02/10] SEARCH-480 - Added a check for date filter --- js/search/search.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/search/search.js b/js/search/search.js index 1b0882f7..062a1330 100644 --- a/js/search/search.js +++ b/js/search/search.js @@ -265,7 +265,10 @@ class Search { let ed_time = MAXIMUM_DATE; if (endDate && endDate !== "") { - ed_time = new Date(parseInt(endDate, 10)).getTime(); + let etime = new Date(parseInt(endDate, 10)).getTime(); + if (etime) { + ed_time = etime + } } if (!_limit && _limit === "" && typeof _limit !== 'number' && Math.round(_limit) !== _limit) { From c93e7a45d7d340022e68875ace6892e8aad1003c Mon Sep 17 00:00:00 2001 From: Keerthi Niranjan Date: Thu, 23 Nov 2017 15:57:26 +0530 Subject: [PATCH 03/10] SEARCH-480 - Fixed the time issue --- js/search/search.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/search/search.js b/js/search/search.js index 062a1330..7b824313 100644 --- a/js/search/search.js +++ b/js/search/search.js @@ -255,10 +255,10 @@ class Search { } let sd = new Date().getTime() - SEARCH_PERIOD_SUBTRACTOR; - let sd_time = MINIMUM_DATE; + let sd_time = sd; if (startDate && startDate !== "") { sd_time = new Date(parseInt(startDate, 10)).getTime(); - if (sd_time >= sd) { + if (sd_time < sd) { sd_time = sd; } } From 65fcd0b786713fc6c34f05788fa67741e393a73a Mon Sep 17 00:00:00 2001 From: Keerthi Niranjan Date: Thu, 23 Nov 2017 16:05:06 +0530 Subject: [PATCH 04/10] SEARCH-480 - Removed a check --- js/search/search.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/js/search/search.js b/js/search/search.js index 7b824313..278ec61f 100644 --- a/js/search/search.js +++ b/js/search/search.js @@ -254,17 +254,17 @@ class Search { return; } - let sd = new Date().getTime() - SEARCH_PERIOD_SUBTRACTOR; - let sd_time = sd; - if (startDate && startDate !== "") { + let searchPeriod = new Date().getTime() - SEARCH_PERIOD_SUBTRACTOR; + let sd_time = searchPeriod; + if (startDate) { sd_time = new Date(parseInt(startDate, 10)).getTime(); - if (sd_time < sd) { - sd_time = sd; + if (sd_time < searchPeriod) { + sd_time = searchPeriod; } } let ed_time = MAXIMUM_DATE; - if (endDate && endDate !== "") { + if (endDate) { let etime = new Date(parseInt(endDate, 10)).getTime(); if (etime) { ed_time = etime From 801259609546145d24286e4fe68d0adf1c2142f4 Mon Sep 17 00:00:00 2001 From: Keerthi Niranjan Date: Thu, 23 Nov 2017 16:55:44 +0530 Subject: [PATCH 05/10] SEARCH-480 - Code refactoring --- js/search/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/search/search.js b/js/search/search.js index 278ec61f..1e5f9fb9 100644 --- a/js/search/search.js +++ b/js/search/search.js @@ -267,7 +267,7 @@ class Search { if (endDate) { let etime = new Date(parseInt(endDate, 10)).getTime(); if (etime) { - ed_time = etime + ed_time = etime; } } From 90dbe8980a039b2a4eeebd58269b12b939c011bc Mon Sep 17 00:00:00 2001 From: Keerthi Niranjan Date: Thu, 23 Nov 2017 17:29:59 +0530 Subject: [PATCH 06/10] SEARCH-480 - Code refactoring --- js/search/search.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/search/search.js b/js/search/search.js index 1e5f9fb9..a63c0e05 100644 --- a/js/search/search.js +++ b/js/search/search.js @@ -258,7 +258,9 @@ class Search { let sd_time = searchPeriod; if (startDate) { sd_time = new Date(parseInt(startDate, 10)).getTime(); - if (sd_time < searchPeriod) { + if (!sd_time) { + sd_time = searchPeriod; + } else if (sd_time < searchPeriod) { sd_time = searchPeriod; } } From d88022d3b56927454a1c6f4a4323502efe98c641 Mon Sep 17 00:00:00 2001 From: Keerthi Niranjan Date: Thu, 23 Nov 2017 18:10:46 +0530 Subject: [PATCH 07/10] SEARCH-480 - Code refactoring --- js/search/search.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/js/search/search.js b/js/search/search.js index a63c0e05..4df03f4e 100644 --- a/js/search/search.js +++ b/js/search/search.js @@ -258,9 +258,7 @@ class Search { let sd_time = searchPeriod; if (startDate) { sd_time = new Date(parseInt(startDate, 10)).getTime(); - if (!sd_time) { - sd_time = searchPeriod; - } else if (sd_time < searchPeriod) { + if (!sd_time || sd_time < searchPeriod) { sd_time = searchPeriod; } } From 7217a30cbb8b594e37a4c504096dfd0d32294f66 Mon Sep 17 00:00:00 2001 From: Keerthi Niranjan Date: Thu, 23 Nov 2017 20:51:32 +0530 Subject: [PATCH 08/10] SEARCH-480 - Code refactoring --- js/search/search.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/js/search/search.js b/js/search/search.js index 4df03f4e..272b161f 100644 --- a/js/search/search.js +++ b/js/search/search.js @@ -255,19 +255,19 @@ class Search { } let searchPeriod = new Date().getTime() - SEARCH_PERIOD_SUBTRACTOR; - let sd_time = searchPeriod; + let startDateTime = searchPeriod; if (startDate) { - sd_time = new Date(parseInt(startDate, 10)).getTime(); - if (!sd_time || sd_time < searchPeriod) { - sd_time = searchPeriod; + startDateTime = new Date(parseInt(startDate, 10)).getTime(); + if (!startDateTime || startDateTime < searchPeriod) { + startDateTime = searchPeriod; } } - let ed_time = MAXIMUM_DATE; + let endDateTime = MAXIMUM_DATE; if (endDate) { - let etime = new Date(parseInt(endDate, 10)).getTime(); - if (etime) { - ed_time = etime; + let eTime = new Date(parseInt(endDate, 10)).getTime(); + if (eTime) { + endDateTime = eTime; } } @@ -283,7 +283,7 @@ class Search { _sortOrder = 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)); From c50763f79e4f010bfa8563562c4dd21a62b50081 Mon Sep 17 00:00:00 2001 From: Keerthi Niranjan Date: Thu, 23 Nov 2017 21:45:37 +0530 Subject: [PATCH 09/10] SEARCH-438 - Code refactoring --- js/search/search.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/js/search/search.js b/js/search/search.js index 8311a6b0..93794b06 100644 --- a/js/search/search.js +++ b/js/search/search.js @@ -111,20 +111,20 @@ class Search { indexBatch(messages) { return new Promise((resolve, reject) => { if (!messages) { - log.send(logLevels.ERROR, 'Messages was not provided for batch indexing'); - reject(new Error('Messages is required')); + log.send(logLevels.ERROR, 'Batch Indexing: Messages not provided'); + reject(new Error('Batch Indexing: Messages is required')); return; } try { let msg = JSON.parse(messages); if (!(msg instanceof Array)) { - log.send(logLevels.ERROR, 'Message must be an array batch indexing'); - reject(new Error('Messages must be an array')); + log.send(logLevels.ERROR, 'Batch Indexing: Messages must be an array'); + reject(new Error('Batch Indexing: Messages must be an array')); return; } } catch(e) { - log.send(logLevels.ERROR, 'Batch indexing parse Error -> ' + e); + log.send(logLevels.ERROR, 'Batch Indexing: parse error -> ' + e); reject(new Error(e)); return; } @@ -138,7 +138,7 @@ class Search { const indexId = randomString.generate(searchConfig.BATCH_RANDOM_INDEX_PATH_LENGTH); libSymphonySearch.symSECreatePartialIndexAsync(this.batchIndex, indexId, messages, (err, res) => { if (err) { - log.send(logLevels.ERROR, 'Error indexing the batch ->' + err); + log.send(logLevels.ERROR, 'Batch Indexing: error ->' + err); reject(new Error(err)); return; } @@ -189,20 +189,19 @@ class Search { * @param message */ realTimeIndexing(message) { - if (!message) { - log.send(logLevels.ERROR, 'Error message not provided for real-time indexing'); - return new Error('Message is required'); + log.send(logLevels.ERROR, 'RealTime Indexing: Messages not provided'); + return new Error('RealTime Indexing: Messages is required'); } try { let msg = JSON.parse(message); if (!(msg instanceof Array)) { - log.send(logLevels.ERROR, 'Message must be an array real-time indexing'); - return (new Error('Messages must be an array')); + log.send(logLevels.ERROR, 'RealTime Indexing: Messages must be an array real-time indexing'); + return (new Error('RealTime Indexing: Messages must be an array')); } } catch(e) { - log.send(logLevels.ERROR, 'Real-time indexing parse Error -> ' + e); + log.send(logLevels.ERROR, 'RealTime Indexing: parse error -> ' + e); return (new Error(e)); } @@ -215,7 +214,7 @@ class Search { return libSymphonySearch.symSEIndexRealTimeAsync(this.realTimeIndex, message, (err, result) => { this.isRealTimeIndexing = false; if (err) { - log.send(logLevels.ERROR, 'Indexing the real-time data -> ' + err); + log.send(logLevels.ERROR, 'RealTime Indexing: error -> ' + err); return new Error(err); } return result; From bb0f3ddf41f531696ad74af98f74757189b309c5 Mon Sep 17 00:00:00 2001 From: Keerthi Niranjan Date: Thu, 23 Nov 2017 21:50:05 +0530 Subject: [PATCH 10/10] SEARCH-438 - Code refactoring --- js/search/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/search/search.js b/js/search/search.js index 89b4e43a..0446e0df 100644 --- a/js/search/search.js +++ b/js/search/search.js @@ -308,7 +308,7 @@ class Search { return; } - let searchPeriod = new Date().getTime() - SEARCH_PERIOD_SUBTRACTOR; + let searchPeriod = new Date().getTime() - searchConfig.SEARCH_PERIOD_SUBTRACTOR; let startDateTime = searchPeriod; if (startDate) { startDateTime = new Date(parseInt(startDate, 10)).getTime();