mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-27 03:54:57 +02:00
UBERF-7543: Add low level groupBy api and improve security space lookup (#6126)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -450,30 +450,8 @@ export class SpaceSecurityMiddleware extends BaseMiddleware implements Middlewar
|
||||
}
|
||||
|
||||
async loadDomainSpaces (ctx: MeasureContext, domain: Domain): Promise<Set<Ref<Space>>> {
|
||||
const map = new Set<Ref<Space>>()
|
||||
const field = this.getKey(domain)
|
||||
while (true) {
|
||||
const nin = Array.from(map.values())
|
||||
const spaces = await this.storage.findAll(
|
||||
ctx,
|
||||
core.class.Doc,
|
||||
nin.length > 0
|
||||
? {
|
||||
[field]: { $nin: nin }
|
||||
}
|
||||
: {},
|
||||
{
|
||||
projection: { [field]: 1 },
|
||||
limit: 1000,
|
||||
domain
|
||||
}
|
||||
)
|
||||
if (spaces.length === 0) {
|
||||
break
|
||||
}
|
||||
spaces.forEach((p) => map.add((p as any)[field] as Ref<Space>))
|
||||
}
|
||||
return map
|
||||
return await this.storage.groupBy<Ref<Space>>(ctx, domain, field)
|
||||
}
|
||||
|
||||
async getDomainSpaces (domain: Domain): Promise<Set<Ref<Space>>> {
|
||||
|
||||
Reference in New Issue
Block a user