From 6cc7ba56d4bf476c52ef215a6e47a22ea10fce78 Mon Sep 17 00:00:00 2001 From: Roman Sergeenko Date: Fri, 24 Jan 2025 13:05:21 +0100 Subject: [PATCH] #RI-6624 - fix slow request for json --- .../browser/rejson-rl/rejson-rl.service.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/redisinsight/api/src/modules/browser/rejson-rl/rejson-rl.service.ts b/redisinsight/api/src/modules/browser/rejson-rl/rejson-rl.service.ts index af2c540ff2..26fe3b8a84 100644 --- a/redisinsight/api/src/modules/browser/rejson-rl/rejson-rl.service.ts +++ b/redisinsight/api/src/modules/browser/rejson-rl/rejson-rl.service.ts @@ -161,7 +161,7 @@ export class RejsonRlService { path: string, type: string, ): Promise { - const result = []; + const promises = []; let objectKeys: string[]; let arrayLength: number; @@ -174,8 +174,8 @@ export class RejsonRlService { ? `['${objectKey}']` : `["${objectKey}"]`; const fullObjectKeyPath = `${rootPath}${childPath}`; - result.push( - await this.getDetails( + promises.push( + this.getDetails( client, keyName, fullObjectKeyPath, @@ -184,26 +184,22 @@ export class RejsonRlService { ); } - break; + return Promise.all(promises); case 'array': arrayLength = await client.sendCommand([ BrowserToolRejsonRlCommands.JsonArrLen, keyName, path, ], { replyEncoding: 'utf8' }) as number; - for (let i = 0; i < arrayLength; i += 1) { const fullObjectKeyPath = `${path === '.' ? '' : path}[${i}]`; - result.push( - await this.getDetails(client, keyName, fullObjectKeyPath, i), - ); + promises.push(this.getDetails(client, keyName, fullObjectKeyPath, i)); } - break; + + return Promise.all(promises); default: return this.forceGetJson(client, keyName, path); } - - return result; } /**