UBER-885: Value filter fix (#3719)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2023-09-20 14:42:37 +07:00 committed by GitHub
parent aa1b41157b
commit 25b048f8e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,19 +74,29 @@
}
const isDerivedFromSpace = hierarchy.isDerived(_class, core.class.Space)
const notArchived =
space === undefined || isDerivedFromSpace
const spaces =
space !== undefined || isDerivedFromSpace
? []
: (await client.findAll(core.class.Space, { archived: { $ne: true } }, { projection: { _id: 1 } })).map(
(it) => it._id
)
: (
await client.findAll(
core.class.Space,
{ archived: { $ne: true } },
{
projection: {
_id: 1,
archived: 1,
_class: 1
}
}
)
).map((it) => it._id)
async function doQuery (limit: number | undefined, first1000?: any[]): Promise<boolean> {
const p = client.findAll(
_class,
{
...resultQuery,
...(space ? { space } : isDerivedFromSpace ? { archived: false } : { space: { $in: notArchived } }),
...(space ? { space } : isDerivedFromSpace ? { archived: false } : { space: { $in: spaces } }),
...(first1000 ? { [filter.key.key]: { $nin: first1000 } } : {})
},
{