Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
perf(backend:spaces): skip childSharesCount execution for child shares linked directly to a space
johavenc6aaae8c0208
diff --git a/backend/src/applications/shares/schemas/shares.schema.ts b/backend/src/applications/shares/schemas/shares.schema.tsindex f4be4d15..3a7e749d 100644--- a/backend/src/applications/shares/schemas/shares.schema.ts+++ b/backend/src/applications/shares/schemas/shares.schema.ts@@ -36,7 +36,7 @@ import { users } from '../../users/schemas/users.schema'- parentId is required- spaceId & spaceRootId must have the same value as their parents- fileId is required when the file is inside the parent share- - fileId is not required when child share is directly link to parent share (with a space root or an external path)+ - fileId is not required when child share is directly linked to parent share (with a space root or an external path)- if the share has an external path : file.shareExternalId must match with the first parent share*/diff --git a/backend/src/applications/spaces/services/spaces-queries.service.ts b/backend/src/applications/spaces/services/spaces-queries.service.tsindex 22a4e0c6..bda216af 100644--- a/backend/src/applications/spaces/services/spaces-queries.service.ts+++ b/backend/src/applications/spaces/services/spaces-queries.service.ts@@ -564,7 +564,7 @@ export class SpacesQueries {groups: countDistinct(spacesMembers.groupId),links: sql`COUNT(DISTINCT(CASE WHEN ${spacesMembers.linkId} IS NOT NULL THEN ${spacesMembers.linkId} END))`,roots: countDistinct(files.id),- shares: sql`CONCAT('[', GROUP_CONCAT(DISTINCT IF(${shares.id} IS NOT NULL, ${shares.id}, NULL)), ']')`.mapWith(JSON.parse)+ shares: sql`COUNT(DISTINCT(CASE WHEN ${shares.id} IS NOT NULL THEN ${shares.id} END))`}}this.spacesWithDetailsQuery = this.db@@ -581,19 +581,7 @@ export class SpacesQueries {.prepare()}const r: MySqlQueryResult = await this.spacesWithDetailsQuery.execute({ userId })- return Promise.all(- r.map(async (s: Partial<SpaceProps>) => {- const shareIds: number[] = popFromObject('shares', s.counts)- s.counts.shares = 0- if (shareIds !== null) {- // get child shares count- for (const sid of shareIds) {- s.counts.shares = s.counts.shares + ((await this.sharesQueries.childSharesCount(sid)) || 1)- }- }- return new SpaceProps(s)- })- )+ return r.length ? r.map((s: Partial<SpaceProps>) => new SpaceProps(s)) : []}@CacheDecorator()