From 1664d6c87354df0513dbe8e8b2a1241bab6016a5 Mon Sep 17 00:00:00 2001 From: Valeriy Zabroddin Date: Wed, 23 Mar 2022 17:40:07 +0000 Subject: [PATCH 1/2] docs: rfcs filter users with or condition --- rfcs/filter-users-with-or-conditions.md | 81 +++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 rfcs/filter-users-with-or-conditions.md diff --git a/rfcs/filter-users-with-or-conditions.md b/rfcs/filter-users-with-or-conditions.md new file mode 100644 index 000000000..a7a28113f --- /dev/null +++ b/rfcs/filter-users-with-or-conditions.md @@ -0,0 +1,81 @@ +# Filter users with or confition + +Provides an ability to get a list of users with different search parameters + +## Why + +For some tasks, we need to implement a search for users by id, name, etc. concurrent search by id and name will be carried out with the condition "and", which will return incomplete data. + +## Solution 1 + +Change schema for users list. + +### Solution 1.1 + +make filter parameter an array + +``` +"filter": { + "type": "array", + "items": { + "$ref": "common.json#/definitions/filter" + }, +} +``` +then we will be able to get users by different filters and merge them + +#### disadvantages + +breaks backward compatibility + +### Solution 1.2 + +add additional property or for filter + +schemas/common.json + +``` +"filter": { + ... + "additionalProperties": { + "oneOf": [ + ... + { + "type": "object", + "minProperties": 1, + "maxProperties": 2, + "patternProperties": { + ... + "or": { + "type": "array", + "items": { + "$ref": "common.json#/definitions/filter" + }, + } + } + } + ] + } +}, +``` +then we will be able to get users by different filters and merge them + +#### disadvantages + +will not be implemented in other filters (invites and organizations) + + +## Solution 2 + +update redis-filtered-sort library + +make https://github.com/makeomatic/redis-filtered-sort possible to accept the parameter "or" + +#### advantages + +it can be used in other projects + +#### disadvantages + +we need more time to develop + From 37031f6e688e5e6881baad7827dd0dc034db1738 Mon Sep 17 00:00:00 2001 From: Valeriy Zabroddin Date: Mon, 28 Mar 2022 08:25:27 +0000 Subject: [PATCH 2/2] feat: filter users with or condition amend rfcs --- rfcs/filter-users-with-or-conditions.md | 36 ++++++------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/rfcs/filter-users-with-or-conditions.md b/rfcs/filter-users-with-or-conditions.md index a7a28113f..a244a564d 100644 --- a/rfcs/filter-users-with-or-conditions.md +++ b/rfcs/filter-users-with-or-conditions.md @@ -6,31 +6,19 @@ Provides an ability to get a list of users with different search parameters For some tasks, we need to implement a search for users by id, name, etc. concurrent search by id and name will be carried out with the condition "and", which will return incomplete data. -## Solution 1 +### Solution -Change schema for users list. +update redis-filtered-sort library -### Solution 1.1 +make https://github.com/makeomatic/redis-filtered-sort possible to accept the parameter "or" -make filter parameter an array +add 'or' value for opType enum -``` -"filter": { - "type": "array", - "items": { - "$ref": "common.json#/definitions/filter" - }, -} -``` -then we will be able to get users by different filters and merge them - -#### disadvantages +if filter contains 'or' field recursively get result fot all filters -breaks backward compatibility -### Solution 1.2 -add additional property or for filter +for ms-users service add additional property or for filter schemas/common.json @@ -60,21 +48,13 @@ schemas/common.json ``` then we will be able to get users by different filters and merge them -#### disadvantages - -will not be implemented in other filters (invites and organizations) - - -## Solution 2 - -update redis-filtered-sort library - -make https://github.com/makeomatic/redis-filtered-sort possible to accept the parameter "or" #### advantages it can be used in other projects +it won't break backward compatibility + #### disadvantages we need more time to develop