From b49bd3d9039e8e424b14f3d4fec1992f61356aeb Mon Sep 17 00:00:00 2001 From: Juan Date: Tue, 3 Jul 2018 17:41:41 +0200 Subject: [PATCH] Filters optimized for numeric values --- client/client/src/index/index.js | 9 +++------ client/item/src/index/index.js | 9 +++------ client/ticket/src/index/index.js | 9 +++------ 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/client/client/src/index/index.js b/client/client/src/index/index.js index 175ddb7d2..2bcf77084 100644 --- a/client/client/src/index/index.js +++ b/client/client/src/index/index.js @@ -10,12 +10,9 @@ export default class Controller { exprBuilder(param, value) { switch (param) { case 'search': - return { - or: [ - {id: value}, - {name: {regexp: value}} - ] - }; + return /^\d+$/.test(value) + ? {id: value} + : {name: {regexp: value}}; case 'phone': return { or: [ diff --git a/client/item/src/index/index.js b/client/item/src/index/index.js index d772e810c..0d8c44717 100644 --- a/client/item/src/index/index.js +++ b/client/item/src/index/index.js @@ -28,12 +28,9 @@ class Controller { exprBuilder(param, value) { switch (param) { case 'search': - return { - or: [ - {id: value}, - {name: {regexp: value}} - ] - }; + return /^\d+$/.test(value) + ? {id: value} + : {name: {regexp: value}}; case 'name': case 'description': return {[param]: {regexp: value}}; diff --git a/client/ticket/src/index/index.js b/client/ticket/src/index/index.js index 813165403..c9792cc9e 100644 --- a/client/ticket/src/index/index.js +++ b/client/ticket/src/index/index.js @@ -59,12 +59,9 @@ export default class Controller { exprBuilder(param, value) { switch (param) { case 'search': - return { - or: [ - {id: value}, - {nickname: {regexp: value}} - ] - }; + return /^\d+$/.test(value) + ? {id: value} + : {nickname: {regexp: value}}; case 'from': return {shipped: {gte: value}}; case 'to':