From efe070e50ea75d6355505c0b5c6fc5576ef7d665 Mon Sep 17 00:00:00 2001 From: Chinmay Zanpure Date: Tue, 5 May 2015 09:32:05 -0700 Subject: [PATCH] Partial-Bug: #1436506 Added support for suffixes on the Stats Query Pages in WebUI Change-Id: Id42240e9d42bb760c5b484df43c50931fa28d7af --- webroot/reports/api/qe.api.js | 44 +++++++-- webroot/reports/views/queries.view | 142 +++++++++++++++++------------ 2 files changed, 120 insertions(+), 66 deletions(-) diff --git a/webroot/reports/api/qe.api.js b/webroot/reports/api/qe.api.js index 82386e53e..0ec9c9f71 100644 --- a/webroot/reports/api/qe.api.js +++ b/webroot/reports/api/qe.api.js @@ -919,16 +919,42 @@ function parseWhereANDClause(whereANDClause) for (i = 0; i < whereANDLength; i += 1) { whereANDArray[i] = whereANDArray[i].trim(); whereANDClause = whereANDArray[i]; - if(whereANDClause.indexOf('Starts with') != -1){ - operator = 'Starts with'; - whereANDClauseArray = whereANDClause.split(operator); - } else if(whereANDClause.indexOf('=') != -1){ - operator = '=' - whereANDClauseArray = whereANDClause.split(operator); + if (whereANDClause.indexOf('&') == -1) { + if (whereANDClause.indexOf('Starts with') != -1) { + operator = 'Starts with'; + whereANDClauseArray = whereANDClause.split(operator); + } else if (whereANDClause.indexOf('=') != -1) { + operator = '='; + whereANDClauseArray = whereANDClause.split(operator); + } + whereANDClause = {"name": "", value: "", op: ""}; + populateWhereANDClause(whereANDClause, whereANDClauseArray[0].trim(), whereANDClauseArray[1].trim(), operator); + whereANDArray[i] = whereANDClause; + } else { + whereANDClauseWithSuffixArrray = whereANDClause.split('&'); + // Treat whereANDClauseWithSuffixArrray[0] as a normal AND term and + // whereANDClauseWithSuffixArrray[1] as a special suffix term + if (whereANDClauseWithSuffixArrray != null && whereANDClauseWithSuffixArrray.length != 0) { + var tempWhereANDClauseWithSuffix; + for (var j = 0; j < whereANDClauseWithSuffixArrray.length; j++) { + if (whereANDClauseWithSuffixArrray[j].indexOf('Starts with') != -1) { + operator = 'Starts with'; + whereANDTerm = whereANDClauseWithSuffixArrray[j].split(operator); + } else if (whereANDClauseWithSuffixArrray[j].indexOf('=') != -1) { + operator = '='; + whereANDTerm = whereANDClauseWithSuffixArrray[j].split(operator); + } + whereANDClause = {"name": "", value: "", op: ""}; + populateWhereANDClause(whereANDClause, whereANDTerm[0].trim(), whereANDTerm[1].trim(), operator); + if (j == 0) { + tempWhereANDClauseWithSuffix = whereANDClause; + } else if (j == 1) { + tempWhereANDClauseWithSuffix.suffix = whereANDClause; + } + } + whereANDArray[i] = tempWhereANDClauseWithSuffix; + } } - whereANDClause = {"name":"", value:"", op:""}; - populateWhereANDClause(whereANDClause, whereANDClauseArray[0].trim(), whereANDClauseArray[1].trim(), operator); - whereANDArray[i] = whereANDClause; } return whereANDArray; }; diff --git a/webroot/reports/views/queries.view b/webroot/reports/views/queries.view index e767e419c..df4308f49 100644 --- a/webroot/reports/views/queries.view +++ b/webroot/reports/views/queries.view @@ -5,15 +5,15 @@