mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
SEARCH-273
- Refactor
This commit is contained in:
@@ -331,12 +331,12 @@ class Search {
|
|||||||
*/
|
*/
|
||||||
static constructQuery(searchQuery, senderId, threadId, fileType) {
|
static constructQuery(searchQuery, senderId, threadId, fileType) {
|
||||||
|
|
||||||
let query = "";
|
let searchText = "";
|
||||||
if(searchQuery !== undefined) {
|
if(searchQuery !== undefined) {
|
||||||
query = searchQuery.trim().toLowerCase(); //to prevent injection of AND and ORs
|
searchText = searchQuery.trim().toLowerCase(); //to prevent injection of AND and ORs
|
||||||
}
|
}
|
||||||
let q = "";
|
let q = "";
|
||||||
let hashTags = Search.getHashTags(query);
|
let hashTags = Search.getHashTags(searchText);
|
||||||
let hashCashTagQuery = "";
|
let hashCashTagQuery = "";
|
||||||
|
|
||||||
if(hashTags.length > 0) {
|
if(hashTags.length > 0) {
|
||||||
@@ -359,10 +359,10 @@ class Search {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (query.length > 0 ) {
|
if (searchText.length > 0 ) {
|
||||||
q = "((text:(" + query + "))" + hashCashTagQuery ;
|
q = "((text:(" + searchText + "))" + hashCashTagQuery ;
|
||||||
if(hasAttachments) {
|
if(hasAttachments) {
|
||||||
q += " OR (filename:(" + query + "))" ;
|
q += " OR (filename:(" + searchText + "))" ;
|
||||||
}
|
}
|
||||||
q = q + ")";
|
q = q + ")";
|
||||||
}
|
}
|
||||||
@@ -386,12 +386,12 @@ class Search {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* appending the senderId and threadId for the query
|
* appending the senderId and threadId for the query
|
||||||
* @param {String} query
|
* @param {String} searchText
|
||||||
* @param {String} fieldName
|
* @param {String} fieldName
|
||||||
* @param {Array} valueArray
|
* @param {Array} valueArray
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
static appendFilterQuery(query, fieldName, valueArray) {
|
static appendFilterQuery(searchText, fieldName, valueArray) {
|
||||||
let q = "";
|
let q = "";
|
||||||
if (valueArray && valueArray.length > 0 ) {
|
if (valueArray && valueArray.length > 0 ) {
|
||||||
|
|
||||||
@@ -400,12 +400,12 @@ class Search {
|
|||||||
q+= "\"" + item + "\" ";
|
q+= "\"" + item + "\" ";
|
||||||
});
|
});
|
||||||
q += "))";
|
q += "))";
|
||||||
if(query.length > 0 ) {
|
if(searchText.length > 0 ) {
|
||||||
q = query + " AND " + q;
|
q = searchText + " AND " + q;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
q = query;
|
q = searchText;
|
||||||
}
|
}
|
||||||
|
|
||||||
return q;
|
return q;
|
||||||
@@ -417,12 +417,12 @@ class Search {
|
|||||||
/**
|
/**
|
||||||
* return the hash cash
|
* return the hash cash
|
||||||
* tags from the query
|
* tags from the query
|
||||||
* @param {String} query
|
* @param {String} searchText
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
static getHashTags(query) {
|
static getHashTags(searchText) {
|
||||||
let hashTags = [];
|
let hashTags = [];
|
||||||
let tokens = query.toLowerCase()
|
let tokens = searchText.toLowerCase()
|
||||||
.trim()
|
.trim()
|
||||||
.replace(/\s\s+/g, ' ')
|
.replace(/\s\s+/g, ' ')
|
||||||
.split(' ').filter((el) => {return el.length !== 0});
|
.split(' ').filter((el) => {return el.length !== 0});
|
||||||
|
|||||||
Reference in New Issue
Block a user