|
@@ -187,27 +187,27 @@ class AdvancedFilter {
|
|
if (commands[i].cmd) {
|
|
if (commands[i].cmd) {
|
|
switch (commands[i].cmd) {
|
|
switch (commands[i].cmd) {
|
|
case '(':
|
|
case '(':
|
|
- {
|
|
|
|
- level++;
|
|
|
|
- if (start === -1) start = i;
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
|
|
+ {
|
|
|
|
+ level++;
|
|
|
|
+ if (start === -1) start = i;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
case ')':
|
|
case ')':
|
|
- {
|
|
|
|
- level--;
|
|
|
|
- commands.splice(i, 1);
|
|
|
|
- i--;
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- default:
|
|
|
|
- {
|
|
|
|
- if (level > 0) {
|
|
|
|
- subcommands.push(commands[i]);
|
|
|
|
|
|
+ {
|
|
|
|
+ level--;
|
|
commands.splice(i, 1);
|
|
commands.splice(i, 1);
|
|
i--;
|
|
i--;
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ default:
|
|
|
|
+ {
|
|
|
|
+ if (level > 0) {
|
|
|
|
+ subcommands.push(commands[i]);
|
|
|
|
+ commands.splice(i, 1);
|
|
|
|
+ i--;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -229,113 +229,112 @@ class AdvancedFilter {
|
|
case '=':
|
|
case '=':
|
|
case '==':
|
|
case '==':
|
|
case '===':
|
|
case '===':
|
|
- {
|
|
|
|
- const field = commands[i - 1].cmd;
|
|
|
|
- const str = commands[i + 1].cmd;
|
|
|
|
- if (commands[i + 1].regex)
|
|
|
|
{
|
|
{
|
|
- const match = str.match(new RegExp('^/(.*?)/([gimy]*)$'));
|
|
|
|
- let regex = null;
|
|
|
|
- if (match.length > 2)
|
|
|
|
- regex = new RegExp(match[1], match[2]);
|
|
|
|
|
|
+ const field = commands[i - 1].cmd;
|
|
|
|
+ const str = commands[i + 1].cmd;
|
|
|
|
+ if (commands[i + 1].regex)
|
|
|
|
+ {
|
|
|
|
+ const match = str.match(new RegExp('^/(.*?)/([gimy]*)$'));
|
|
|
|
+ let regex = null;
|
|
|
|
+ if (match.length > 2)
|
|
|
|
+ regex = new RegExp(match[1], match[2]);
|
|
|
|
+ else
|
|
|
|
+ regex = new RegExp(match[1]);
|
|
|
|
+ commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': regex };
|
|
|
|
+ }
|
|
else
|
|
else
|
|
- regex = new RegExp(match[1]);
|
|
|
|
- commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': regex };
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': {$in: [this._fieldValueToId(field, str), parseInt(str, 10)]} };
|
|
|
|
|
|
+ {
|
|
|
|
+ commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': {$in: [this._fieldValueToId(field, str), parseInt(str, 10)]} };
|
|
|
|
+ }
|
|
|
|
+ commands.splice(i - 1, 1);
|
|
|
|
+ commands.splice(i, 1);
|
|
|
|
+ //changed = true;
|
|
|
|
+ i--;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
- commands.splice(i - 1, 1);
|
|
|
|
- commands.splice(i, 1);
|
|
|
|
- //changed = true;
|
|
|
|
- i--;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
case '!=':
|
|
case '!=':
|
|
case '!==':
|
|
case '!==':
|
|
- {
|
|
|
|
- const field = commands[i - 1].cmd;
|
|
|
|
- const str = commands[i + 1].cmd;
|
|
|
|
- if (commands[i + 1].regex)
|
|
|
|
{
|
|
{
|
|
- const match = str.match(new RegExp('^/(.*?)/([gimy]*)$'));
|
|
|
|
- let regex = null;
|
|
|
|
- if (match.length > 2)
|
|
|
|
- regex = new RegExp(match[1], match[2]);
|
|
|
|
|
|
+ const field = commands[i - 1].cmd;
|
|
|
|
+ const str = commands[i + 1].cmd;
|
|
|
|
+ if (commands[i + 1].regex)
|
|
|
|
+ {
|
|
|
|
+ const match = str.match(new RegExp('^/(.*?)/([gimy]*)$'));
|
|
|
|
+ let regex = null;
|
|
|
|
+ if (match.length > 2)
|
|
|
|
+ regex = new RegExp(match[1], match[2]);
|
|
|
|
+ else
|
|
|
|
+ regex = new RegExp(match[1]);
|
|
|
|
+ commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $not: regex } };
|
|
|
|
+ }
|
|
else
|
|
else
|
|
- regex = new RegExp(match[1]);
|
|
|
|
- commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $not: regex } };
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $not: {$in: [this._fieldValueToId(field, str), parseInt(str, 10)]} } };
|
|
|
|
|
|
+ {
|
|
|
|
+ commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $not: {$in: [this._fieldValueToId(field, str), parseInt(str, 10)]} } };
|
|
|
|
+ }
|
|
|
|
+ commands.splice(i - 1, 1);
|
|
|
|
+ commands.splice(i, 1);
|
|
|
|
+ //changed = true;
|
|
|
|
+ i--;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
- commands.splice(i - 1, 1);
|
|
|
|
- commands.splice(i, 1);
|
|
|
|
- //changed = true;
|
|
|
|
- i--;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
case '>':
|
|
case '>':
|
|
case 'gt':
|
|
case 'gt':
|
|
case 'Gt':
|
|
case 'Gt':
|
|
case 'GT':
|
|
case 'GT':
|
|
- {
|
|
|
|
- const field = commands[i - 1].cmd;
|
|
|
|
- const str = commands[i + 1].cmd;
|
|
|
|
- commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $gt: parseInt(str, 10) } };
|
|
|
|
- commands.splice(i - 1, 1);
|
|
|
|
- commands.splice(i, 1);
|
|
|
|
- //changed = true;
|
|
|
|
- i--;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ {
|
|
|
|
+ const field = commands[i - 1].cmd;
|
|
|
|
+ const str = commands[i + 1].cmd;
|
|
|
|
+ commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $gt: parseInt(str, 10) } };
|
|
|
|
+ commands.splice(i - 1, 1);
|
|
|
|
+ commands.splice(i, 1);
|
|
|
|
+ //changed = true;
|
|
|
|
+ i--;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
case '>=':
|
|
case '>=':
|
|
case '>==':
|
|
case '>==':
|
|
case 'gte':
|
|
case 'gte':
|
|
case 'Gte':
|
|
case 'Gte':
|
|
case 'GTE':
|
|
case 'GTE':
|
|
- {
|
|
|
|
- const field = commands[i - 1].cmd;
|
|
|
|
- const str = commands[i + 1].cmd;
|
|
|
|
- commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $gte: parseInt(str, 10) } };
|
|
|
|
- commands.splice(i - 1, 1);
|
|
|
|
- commands.splice(i, 1);
|
|
|
|
- //changed = true;
|
|
|
|
- i--;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ {
|
|
|
|
+ const field = commands[i - 1].cmd;
|
|
|
|
+ const str = commands[i + 1].cmd;
|
|
|
|
+ commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $gte: parseInt(str, 10) } };
|
|
|
|
+ commands.splice(i - 1, 1);
|
|
|
|
+ commands.splice(i, 1);
|
|
|
|
+ //changed = true;
|
|
|
|
+ i--;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
case '<':
|
|
case '<':
|
|
case 'lt':
|
|
case 'lt':
|
|
case 'Lt':
|
|
case 'Lt':
|
|
case 'LT':
|
|
case 'LT':
|
|
- {
|
|
|
|
- const field = commands[i - 1].cmd;
|
|
|
|
- const str = commands[i + 1].cmd;
|
|
|
|
- commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $lt: parseInt(str, 10) } };
|
|
|
|
- commands.splice(i - 1, 1);
|
|
|
|
- commands.splice(i, 1);
|
|
|
|
- //changed = true;
|
|
|
|
- i--;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ {
|
|
|
|
+ const field = commands[i - 1].cmd;
|
|
|
|
+ const str = commands[i + 1].cmd;
|
|
|
|
+ commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $lt: parseInt(str, 10) } };
|
|
|
|
+ commands.splice(i - 1, 1);
|
|
|
|
+ commands.splice(i, 1);
|
|
|
|
+ //changed = true;
|
|
|
|
+ i--;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
case '<=':
|
|
case '<=':
|
|
case '<==':
|
|
case '<==':
|
|
case 'lte':
|
|
case 'lte':
|
|
case 'Lte':
|
|
case 'Lte':
|
|
case 'LTE':
|
|
case 'LTE':
|
|
- {
|
|
|
|
- const field = commands[i - 1].cmd;
|
|
|
|
- const str = commands[i + 1].cmd;
|
|
|
|
- commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $lte: parseInt(str, 10) } };
|
|
|
|
- commands.splice(i - 1, 1);
|
|
|
|
- commands.splice(i, 1);
|
|
|
|
- //changed = true;
|
|
|
|
- i--;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ {
|
|
|
|
+ const field = commands[i - 1].cmd;
|
|
|
|
+ const str = commands[i + 1].cmd;
|
|
|
|
+ commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $lte: parseInt(str, 10) } };
|
|
|
|
+ commands.splice(i - 1, 1);
|
|
|
|
+ commands.splice(i, 1);
|
|
|
|
+ //changed = true;
|
|
|
|
+ i--;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -350,45 +349,43 @@ class AdvancedFilter {
|
|
case 'OR':
|
|
case 'OR':
|
|
case '|':
|
|
case '|':
|
|
case '||':
|
|
case '||':
|
|
- {
|
|
|
|
- const op1 = commands[i - 1];
|
|
|
|
- const op2 = commands[i + 1];
|
|
|
|
- commands[i] = { $or: [op1, op2] };
|
|
|
|
- commands.splice(i - 1, 1);
|
|
|
|
- commands.splice(i, 1);
|
|
|
|
- //changed = true;
|
|
|
|
- i--;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ {
|
|
|
|
+ const op1 = commands[i - 1];
|
|
|
|
+ const op2 = commands[i + 1];
|
|
|
|
+ commands[i] = { $or: [op1, op2] };
|
|
|
|
+ commands.splice(i - 1, 1);
|
|
|
|
+ commands.splice(i, 1);
|
|
|
|
+ //changed = true;
|
|
|
|
+ i--;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
case 'and':
|
|
case 'and':
|
|
case 'And':
|
|
case 'And':
|
|
case 'AND':
|
|
case 'AND':
|
|
case '&':
|
|
case '&':
|
|
case '&&':
|
|
case '&&':
|
|
- {
|
|
|
|
- const op1 = commands[i - 1];
|
|
|
|
- const op2 = commands[i + 1];
|
|
|
|
- commands[i] = { $and: [op1, op2] };
|
|
|
|
- commands.splice(i - 1, 1);
|
|
|
|
- commands.splice(i, 1);
|
|
|
|
- //changed = true;
|
|
|
|
- i--;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ {
|
|
|
|
+ const op1 = commands[i - 1];
|
|
|
|
+ const op2 = commands[i + 1];
|
|
|
|
+ commands[i] = { $and: [op1, op2] };
|
|
|
|
+ commands.splice(i - 1, 1);
|
|
|
|
+ commands.splice(i, 1);
|
|
|
|
+ //changed = true;
|
|
|
|
+ i--;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
case 'not':
|
|
case 'not':
|
|
case 'Not':
|
|
case 'Not':
|
|
case 'NOT':
|
|
case 'NOT':
|
|
case '!':
|
|
case '!':
|
|
- {
|
|
|
|
- const op1 = commands[i + 1];
|
|
|
|
- commands[i] = { $not: op1 };
|
|
|
|
- commands.splice(i + 1, 1);
|
|
|
|
- //changed = true;
|
|
|
|
- i--;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ {
|
|
|
|
+ const op1 = commands[i + 1];
|
|
|
|
+ commands[i] = { $not: op1 };
|
|
|
|
+ commands.splice(i + 1, 1);
|
|
|
|
+ //changed = true;
|
|
|
|
+ i--;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|