|
|
|
@ -163,27 +163,27 @@ class AdvancedFilter { |
|
|
|
|
if (commands[i].cmd) { |
|
|
|
|
switch (commands[i].cmd) { |
|
|
|
|
case '(': |
|
|
|
|
{ |
|
|
|
|
level++; |
|
|
|
|
if (start === -1) start = i; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
level++; |
|
|
|
|
if (start === -1) start = i; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
case ')': |
|
|
|
|
{ |
|
|
|
|
level--; |
|
|
|
|
{ |
|
|
|
|
level--; |
|
|
|
|
commands.splice(i, 1); |
|
|
|
|
i--; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
|
{ |
|
|
|
|
if (level > 0) { |
|
|
|
|
subcommands.push(commands[i]); |
|
|
|
|
commands.splice(i, 1); |
|
|
|
|
i--; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
|
{ |
|
|
|
|
if (level > 0) { |
|
|
|
|
subcommands.push(commands[i]); |
|
|
|
|
commands.splice(i, 1); |
|
|
|
|
i--; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -205,86 +205,86 @@ class AdvancedFilter { |
|
|
|
|
case '=': |
|
|
|
|
case '==': |
|
|
|
|
case '===': |
|
|
|
|
{ |
|
|
|
|
const field = commands[i - 1].cmd; |
|
|
|
|
const str = commands[i + 1].cmd; |
|
|
|
|
commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': str }; |
|
|
|
|
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': str }; |
|
|
|
|
commands.splice(i - 1, 1); |
|
|
|
|
commands.splice(i, 1); |
|
|
|
|
//changed = true;
|
|
|
|
|
i--; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case '!=': |
|
|
|
|
case '!==': |
|
|
|
|
{ |
|
|
|
|
const field = commands[i - 1].cmd; |
|
|
|
|
const str = commands[i + 1].cmd; |
|
|
|
|
commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $not: str } }; |
|
|
|
|
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': { $not: str } }; |
|
|
|
|
commands.splice(i - 1, 1); |
|
|
|
|
commands.splice(i, 1); |
|
|
|
|
//changed = true;
|
|
|
|
|
i--; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case '>': |
|
|
|
|
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: str } }; |
|
|
|
|
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: str } }; |
|
|
|
|
commands.splice(i - 1, 1); |
|
|
|
|
commands.splice(i, 1); |
|
|
|
|
//changed = true;
|
|
|
|
|
i--; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case '>=': |
|
|
|
|
case '>==': |
|
|
|
|
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: str } }; |
|
|
|
|
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: str } }; |
|
|
|
|
commands.splice(i - 1, 1); |
|
|
|
|
commands.splice(i, 1); |
|
|
|
|
//changed = true;
|
|
|
|
|
i--; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case '<': |
|
|
|
|
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: str } }; |
|
|
|
|
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: str } }; |
|
|
|
|
commands.splice(i - 1, 1); |
|
|
|
|
commands.splice(i, 1); |
|
|
|
|
//changed = true;
|
|
|
|
|
i--; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case '<=': |
|
|
|
|
case '<==': |
|
|
|
|
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: str } }; |
|
|
|
|
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: str } }; |
|
|
|
|
commands.splice(i - 1, 1); |
|
|
|
|
commands.splice(i, 1); |
|
|
|
|
//changed = true;
|
|
|
|
|
i--; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -300,44 +300,44 @@ class AdvancedFilter { |
|
|
|
|
case 'OR': |
|
|
|
|
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 '&': |
|
|
|
|
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 '!': |
|
|
|
|
{ |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|