From 281c92a1e274b9a4584d937e57de9d75e820287d Mon Sep 17 00:00:00 2001 From: Amir Allayarov Date: Thu, 25 May 2023 02:54:00 +0700 Subject: [PATCH 1/4] #RI-4566 - update recommendation conditions --- .../src/common/constants/recommendations.ts | 7 +- .../api/src/constants/recommendations.ts | 2 - .../set-business/set-business.service.spec.ts | 10 --- .../set-business/set-business.service.ts | 10 --- .../scanner/recommendation.provider.spec.ts | 1 - .../scanner/recommendation.provider.ts | 1 - .../integer-in-set.strategy.spec.ts | 57 -------------- .../strategies/integer-in-set.strategy.ts | 28 ------- .../providers/recommendation.provider.spec.ts | 10 +-- .../recommendation/recommendation.service.ts | 4 - .../POST-databases-id-analysis.test.ts | 6 +- .../WS-new-recommendations.test.ts | 2 +- .../constants/dbAnalysisRecommendations.json | 74 ------------------- 13 files changed, 12 insertions(+), 200 deletions(-) delete mode 100644 redisinsight/api/src/modules/database-recommendation/scanner/strategies/integer-in-set.strategy.spec.ts delete mode 100644 redisinsight/api/src/modules/database-recommendation/scanner/strategies/integer-in-set.strategy.ts diff --git a/redisinsight/api/src/common/constants/recommendations.ts b/redisinsight/api/src/common/constants/recommendations.ts index 87813961f5..0fd302e522 100644 --- a/redisinsight/api/src/common/constants/recommendations.ts +++ b/redisinsight/api/src/common/constants/recommendations.ts @@ -14,13 +14,12 @@ export const COMBINE_SMALL_STRINGS_TO_HASHES_RECOMMENDATION_MEMORY = 200; export const USE_SMALLER_KEYS_RECOMMENDATION_TOTAL = 1_000_000; export const COMPRESS_HASH_FIELD_NAMES_RECOMMENDATION_LENGTH = 1000; export const COMPRESSION_FOR_LIST_RECOMMENDATION_LENGTH = 1000; -export const BIG_SETS_RECOMMENDATION_LENGTH = 100_000; +export const BIG_SETS_RECOMMENDATION_LENGTH = 1_000; export const BIG_AMOUNT_OF_CONNECTED_CLIENTS_RECOMMENDATION_CLIENTS = 100; -export const BIG_STRINGS_RECOMMENDATION_MEMORY = 1_000_000; +export const BIG_STRINGS_RECOMMENDATION_MEMORY = 100_000; export const RTS_RECOMMENDATION_PERCENTAGE = 99; export const SEARCH_INDEXES_RECOMMENDATION_KEYS_FOR_CHECK = 100; export const REDIS_VERSION_RECOMMENDATION_VERSION = '6'; -export const COMBINE_SMALL_STRINGS_TO_HASHES_RECOMMENDATION_KEYS_COUNT = 50; -export const INTEGERS_IN_SET_RECOMMENDATION_MEMBERS_FOR_CHECK = 50; +export const COMBINE_SMALL_STRINGS_TO_HASHES_RECOMMENDATION_KEYS_COUNT = 10; export const SEARCH_HASH_RECOMMENDATION_KEYS_FOR_CHECK = 50; export const SEARCH_HASH_RECOMMENDATION_KEYS_LENGTH = 2; diff --git a/redisinsight/api/src/constants/recommendations.ts b/redisinsight/api/src/constants/recommendations.ts index 18cbff826c..7911eafc2b 100644 --- a/redisinsight/api/src/constants/recommendations.ts +++ b/redisinsight/api/src/constants/recommendations.ts @@ -17,7 +17,6 @@ export const RECOMMENDATION_NAMES = Object.freeze({ REDIS_VERSION: 'redisVersion', SEARCH_INDEXES: 'searchIndexes', SEARCH_JSON: 'searchJSON', - INTEGERS_IN_SET: 'integersInSets', STRING_TO_JSON: 'stringToJson', SEARCH_VISUALIZATION: 'searchVisualization', SEARCH_HASH: 'searchHash', @@ -38,6 +37,5 @@ export const REDIS_STACK = [ RECOMMENDATION_NAMES.REDIS_VERSION, RECOMMENDATION_NAMES.SEARCH_INDEXES, RECOMMENDATION_NAMES.SEARCH_JSON, - RECOMMENDATION_NAMES.INTEGERS_IN_SET, RECOMMENDATION_NAMES.STRING_TO_JSON, ] diff --git a/redisinsight/api/src/modules/browser/services/set-business/set-business.service.spec.ts b/redisinsight/api/src/modules/browser/services/set-business/set-business.service.spec.ts index b79b492894..29086fc600 100644 --- a/redisinsight/api/src/modules/browser/services/set-business/set-business.service.spec.ts +++ b/redisinsight/api/src/modules/browser/services/set-business/set-business.service.spec.ts @@ -339,16 +339,6 @@ describe('SetBusinessService', () => { mockBrowserClientMetadata, mockGetSetMembersDto, ); - expect(recommendationService.check).toBeCalledWith( - mockBrowserClientMetadata, - RECOMMENDATION_NAMES.INTEGERS_IN_SET, - { - members: result.members, - keyName: result.keyName, - client: nodeClient, - databaseId: mockBrowserClientMetadata.databaseId, - }, - ); expect(recommendationService.check).toBeCalledTimes(1); }); diff --git a/redisinsight/api/src/modules/browser/services/set-business/set-business.service.ts b/redisinsight/api/src/modules/browser/services/set-business/set-business.service.ts index 2174d36773..2dfffaf0ce 100644 --- a/redisinsight/api/src/modules/browser/services/set-business/set-business.service.ts +++ b/redisinsight/api/src/modules/browser/services/set-business/set-business.service.ts @@ -120,16 +120,6 @@ export class SetBusinessService { const scanResult = await this.scanSet(clientMetadata, dto); result = { ...result, ...scanResult }; } - this.recommendationService.check( - clientMetadata, - RECOMMENDATION_NAMES.INTEGERS_IN_SET, - { - members: result.members, - keyName, - client, - databaseId: clientMetadata.databaseId, - }, - ); this.logger.log('Succeed to get members of the Set data type.'); return plainToClass(GetSetMembersResponse, result); } catch (error) { diff --git a/redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.spec.ts b/redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.spec.ts index 017eb9edab..689f44ab6d 100644 --- a/redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.spec.ts +++ b/redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.spec.ts @@ -44,7 +44,6 @@ describe('RecommendationProvider', () => { [RECOMMENDATION_NAMES.REDIS_VERSION, new RedisVersionStrategy()], [RECOMMENDATION_NAMES.BIG_SETS, new BigSetStrategy()], [RECOMMENDATION_NAMES.RTS, new RTSStrategy()], - [RECOMMENDATION_NAMES.INTEGERS_IN_SET, new IntegersInSetStrategy()], [RECOMMENDATION_NAMES.AVOID_LOGICAL_DATABASES, new AvoidLogicalDatabasesStrategy()], [RECOMMENDATION_NAMES.BIG_HASHES, new ShardHashStrategy()], [RECOMMENDATION_NAMES.STRING_TO_JSON, new StringToJsonStrategy()], diff --git a/redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.ts b/redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.ts index 7d3fc9dd32..a0a30fa1d1 100644 --- a/redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.ts +++ b/redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.ts @@ -35,7 +35,6 @@ export class RecommendationProvider { this.strategies.set(RECOMMENDATION_NAMES.SEARCH_JSON, new SearchJSONStrategy(databaseService)); this.strategies.set(RECOMMENDATION_NAMES.BIG_SETS, new BigSetStrategy()); this.strategies.set(RECOMMENDATION_NAMES.RTS, new RTSStrategy()); - this.strategies.set(RECOMMENDATION_NAMES.INTEGERS_IN_SET, new IntegersInSetStrategy()); this.strategies.set(RECOMMENDATION_NAMES.AVOID_LOGICAL_DATABASES, new AvoidLogicalDatabasesStrategy()); this.strategies.set(RECOMMENDATION_NAMES.BIG_HASHES, new ShardHashStrategy()); this.strategies.set(RECOMMENDATION_NAMES.STRING_TO_JSON, new StringToJsonStrategy()); diff --git a/redisinsight/api/src/modules/database-recommendation/scanner/strategies/integer-in-set.strategy.spec.ts b/redisinsight/api/src/modules/database-recommendation/scanner/strategies/integer-in-set.strategy.spec.ts deleted file mode 100644 index 8358212bc5..0000000000 --- a/redisinsight/api/src/modules/database-recommendation/scanner/strategies/integer-in-set.strategy.spec.ts +++ /dev/null @@ -1,57 +0,0 @@ -import IORedis from 'ioredis'; -import { IntegersInSetStrategy } from 'src/modules/database-recommendation/scanner/strategies'; -import { RedisString } from 'src/common/constants'; - -const nodeClient = Object.create(IORedis.prototype); -nodeClient.sendCommand = jest.fn(); - -const mockDatabaseId = 'id'; - -const mockKeyName = 'name'; - -const mockNotIntegerMembers: RedisString[] = ['a'].map((val) => Buffer.from(val)); -const mockIntegerMembers: RedisString[] = [ - '0', - '1', - '1.1', - '0.999999', - '123123123123', - '6854785734', -].map((val) => Buffer.from(val)); - -describe('IntegersInSetStrategy', () => { - let strategy: IntegersInSetStrategy; - - beforeEach(async () => { - strategy = new IntegersInSetStrategy(); - }); - - describe('isRecommendationReached', () => { - it('should return false when all members is an integer', async () => { - expect(await strategy.isRecommendationReached({ - client: nodeClient, - databaseId: mockDatabaseId, - members: [...mockIntegerMembers], - keyName: mockKeyName, - })).toEqual({ isReached: false }); - }); - - it('should return false when some member is not an integer in the first 50 members', async () => { - expect(await strategy.isRecommendationReached({ - client: nodeClient, - databaseId: mockDatabaseId, - members: [...mockIntegerMembers, ...mockNotIntegerMembers] as RedisString[], - keyName: mockKeyName, - })).toEqual({ isReached: true, params: { keys: [mockKeyName] } }); - }); - - it('should return false when 51th member is not an integer', async () => { - expect(await strategy.isRecommendationReached({ - client: nodeClient, - databaseId: mockDatabaseId, - members: [...Array.from({ length: 50 }).fill(mockIntegerMembers[0]), ...mockNotIntegerMembers] as RedisString[], - keyName: mockKeyName, - })).toEqual({ isReached: false }); - }); - }); -}); diff --git a/redisinsight/api/src/modules/database-recommendation/scanner/strategies/integer-in-set.strategy.ts b/redisinsight/api/src/modules/database-recommendation/scanner/strategies/integer-in-set.strategy.ts deleted file mode 100644 index 09b39536e5..0000000000 --- a/redisinsight/api/src/modules/database-recommendation/scanner/strategies/integer-in-set.strategy.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { isNaN, toNumber } from 'lodash'; -import { AbstractRecommendationStrategy } - from 'src/modules/database-recommendation/scanner/strategies/abstract.recommendation.strategy'; -import { IDatabaseRecommendationStrategyData } - from 'src/modules/database-recommendation/scanner/recommendation.strategy.interface'; -import { IntegersInSets } from 'src/modules/database-recommendation/models'; -import { getUTF8FromRedisString } from 'src/utils/cli-helper'; -import { INTEGERS_IN_SET_RECOMMENDATION_MEMBERS_FOR_CHECK } from 'src/common/constants'; - -export class IntegersInSetStrategy extends AbstractRecommendationStrategy { - /** - * Check integers in sets recommendation - * @param data - */ - - async isRecommendationReached( - data: IntegersInSets, - ): Promise { - const membersForCheck = data?.members?.slice(0, INTEGERS_IN_SET_RECOMMENDATION_MEMBERS_FOR_CHECK); - const isNotIntegerInSet = membersForCheck.some( - (member) => isNaN(toNumber(getUTF8FromRedisString(member))), - ); - - return isNotIntegerInSet - ? { isReached: true, params: { keys: [data?.keyName] } } - : { isReached: false }; - } -} diff --git a/redisinsight/api/src/modules/recommendation/providers/recommendation.provider.spec.ts b/redisinsight/api/src/modules/recommendation/providers/recommendation.provider.spec.ts index 409455b19d..92d55e87ac 100644 --- a/redisinsight/api/src/modules/recommendation/providers/recommendation.provider.spec.ts +++ b/redisinsight/api/src/modules/recommendation/providers/recommendation.provider.spec.ts @@ -77,7 +77,7 @@ const mockBigStringKey = { }; const mockHugeStringKey = { - name: Buffer.from('name'), type: 'string', length: 10, memory: 1_000_001, ttl: -1, + name: Buffer.from('name'), type: 'string', length: 10, memory: 100_001, ttl: -1, }; const mockHugeStringKey1 = { @@ -89,7 +89,7 @@ const mockBigSet = { }; const mockHugeSet = { - name: Buffer.from('name'), type: 'set', length: 100_001, memory: 10, ttl: -1, + name: Buffer.from('name'), type: 'set', length: 1_001, memory: 10, ttl: -1, }; const mockBigZSetKey = { @@ -214,18 +214,18 @@ describe('RecommendationProvider', () => { describe('determineCombineSmallStringsToHashesRecommendation', () => { it('should not return combineSmallStringsToHashes recommendation', async () => { const smallStringRecommendation = await service.determineCombineSmallStringsToHashesRecommendation( - new Array(49).fill(mockSmallStringKey), + new Array(9).fill(mockSmallStringKey), ); expect(smallStringRecommendation).toEqual(null); }); it('should not return combineSmallStringsToHashes recommendation when strings are big', async () => { const smallStringRecommendation = await service.determineCombineSmallStringsToHashesRecommendation( - new Array(50).fill(mockBigStringKey), + new Array(10).fill(mockBigStringKey), ); expect(smallStringRecommendation).toEqual(null); }); it('should return combineSmallStringsToHashes recommendation', async () => { - const smallStringRecommendation = await service.determineCombineSmallStringsToHashesRecommendation(new Array(50).fill(mockSmallStringKey)); + const smallStringRecommendation = await service.determineCombineSmallStringsToHashesRecommendation(new Array(10).fill(mockSmallStringKey)); expect(smallStringRecommendation) .toEqual({ name: RECOMMENDATION_NAMES.COMBINE_SMALL_STRINGS_TO_HASHES, diff --git a/redisinsight/api/src/modules/recommendation/recommendation.service.ts b/redisinsight/api/src/modules/recommendation/recommendation.service.ts index 98decc3edc..967a609655 100644 --- a/redisinsight/api/src/modules/recommendation/recommendation.service.ts +++ b/redisinsight/api/src/modules/recommendation/recommendation.service.ts @@ -120,10 +120,6 @@ export class RecommendationService { RECOMMENDATION_NAMES.STRING_TO_JSON, () => null, ], - [ - RECOMMENDATION_NAMES.INTEGERS_IN_SET, - () => null, - ], [ RECOMMENDATION_NAMES.SEARCH_JSON, async () => await this.recommendationProvider.determineSearchJSONRecommendation(keys, indexes), diff --git a/redisinsight/api/test/api/database-analysis/POST-databases-id-analysis.test.ts b/redisinsight/api/test/api/database-analysis/POST-databases-id-analysis.test.ts index c2f3cd1183..b633c29215 100644 --- a/redisinsight/api/test/api/database-analysis/POST-databases-id-analysis.test.ts +++ b/redisinsight/api/test/api/database-analysis/POST-databases-id-analysis.test.ts @@ -203,7 +203,7 @@ describe('POST /databases/:instanceId/analysis', () => { statusCode: 201, responseSchema, before: async () => { - await rte.data.generateHugeNumberOfTinyStringKeys(50); + await rte.data.generateHugeNumberOfTinyStringKeys(10); }, checkFn: async ({ body }) => { // can not predict keys order, params.keys is random @@ -533,7 +533,7 @@ describe('POST /databases/:instanceId/analysis', () => { statusCode: 201, responseSchema, before: async () => { - const BIG_STRING_MEMORY = 5_000_001; + const BIG_STRING_MEMORY = 100_001; const bigStringValue = Buffer.alloc(BIG_STRING_MEMORY, 'a').toString(); await rte.data.sendCommand('set', [constants.TEST_STRING_KEY_1, bigStringValue]); @@ -577,7 +577,7 @@ describe('POST /databases/:instanceId/analysis', () => { statusCode: 201, responseSchema, before: async () => { - const NUMBERS_OF_SET_MEMBERS = 100_001; + const NUMBERS_OF_SET_MEMBERS = 1_001; await rte.data.generateHugeNumberOfMembersForSetKey(NUMBERS_OF_SET_MEMBERS, true); }, checkFn: async ({ body }) => { diff --git a/redisinsight/api/test/api/database-recommendations/WS-new-recommendations.test.ts b/redisinsight/api/test/api/database-recommendations/WS-new-recommendations.test.ts index 7963e01464..d9b1c8d88a 100644 --- a/redisinsight/api/test/api/database-recommendations/WS-new-recommendations.test.ts +++ b/redisinsight/api/test/api/database-recommendations/WS-new-recommendations.test.ts @@ -28,7 +28,7 @@ describe('WS new recommendations', () => { it('Should notify about new big set recommendations', async () => { // generate big set - const NUMBERS_OF_SET_MEMBERS = 100_001; + const NUMBERS_OF_SET_MEMBERS = 1_001; await rte.data.generateHugeNumberOfMembersForSetKey(NUMBERS_OF_SET_MEMBERS, true); // Initialize sync by connecting diff --git a/redisinsight/ui/src/constants/dbAnalysisRecommendations.json b/redisinsight/ui/src/constants/dbAnalysisRecommendations.json index 098737110a..c7b11291a1 100644 --- a/redisinsight/ui/src/constants/dbAnalysisRecommendations.json +++ b/redisinsight/ui/src/constants/dbAnalysisRecommendations.json @@ -961,80 +961,6 @@ } ] }, - "integersInSets": { - "id": "integersInSets", - "redisStack": true, - "title": "Use only integers in sets to improve memory efficiency", - "tutorial": "/quick-guides/document/working-with-hashes.md", - "content": [ - { - "type": "paragraph", - "value": "Sets that contain only integers are extremely efficient memory-wise. Try to use integers by mapping string identifiers to integers by either using enums in your programming language or using a Redis hash data structure to map values to integers." - }, - { - "type": "spacer", - "value": "l" - }, - { - "type": "paragraph", - "value": "Once you switch to integers, Redis uses the IntSet encoding internally." - }, - { - "type": "spacer", - "value": "l" - }, - { - "type": "span", - "value": "The IntSet encoding is extremely memory efficient. By default, the value of " - }, - { - "type": "code", - "value": "set-max-intset-entries" - }, - { - "type": "span", - "value": " is 512 and is configurable in redis.conf. However, increasing this value will lead to an increase in the latency of set operations and CPU utilization." - }, - { - "type": "spacer", - "value": "l" - }, - { - "type": "span", - "value": "Run " - }, - { - "type": "code-link", - "value": { - "href": "https://redis.io/commands/info/", - "name": "INFO COMMANDSTATS" - } - }, - { - "type": "span", - "value": " before and after making this change to verify the latency numbers." - }, - { - "type": "spacer", - "value": "l" - }, - { - "type": "span", - "value": "See the " - }, - { - "type": "link", - "value": { - "href": "https://redis.io/docs/management/optimization/memory-optimization/", - "name": "documentation" - } - }, - { - "type": "span", - "value": " for more memory optimization strategies." - } - ] - }, "stringToJson": { "id": "stringToJson", "title": "Try using our JSON native document store", From d3524144df1657b90905abaeabe9286c18c83540 Mon Sep 17 00:00:00 2001 From: Amir Allayarov Date: Thu, 25 May 2023 03:09:54 +0700 Subject: [PATCH 2/4] #RI-4566 - remove unused code --- .../modules/database-recommendation/scanner/strategies/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/redisinsight/api/src/modules/database-recommendation/scanner/strategies/index.ts b/redisinsight/api/src/modules/database-recommendation/scanner/strategies/index.ts index 0ce076f9ff..cd00f468bc 100644 --- a/redisinsight/api/src/modules/database-recommendation/scanner/strategies/index.ts +++ b/redisinsight/api/src/modules/database-recommendation/scanner/strategies/index.ts @@ -5,7 +5,6 @@ export * from './search-JSON.strategy'; export * from './big-set.strategy'; export * from './rts.strategy'; export * from './avoid-logical-databases.strategy'; -export * from './integer-in-set.strategy'; export * from './shard-hash.strategy'; export * from './string-to-json.strategy'; export * from './search-visualization.strategy'; From 0f69da8b3d1ba53bafbb260fb9a58b14dd9d892e Mon Sep 17 00:00:00 2001 From: Amir Allayarov Date: Thu, 25 May 2023 03:29:12 +0700 Subject: [PATCH 3/4] #RI-4566 - fix tests --- .../set-business/set-business.service.spec.ts | 25 ------------------- .../set-business/set-business.service.ts | 5 +--- .../scanner/recommendation.provider.spec.ts | 1 - .../scanner/recommendation.provider.ts | 1 - .../strategies/big-set.strategy.spec.ts | 8 +++--- 5 files changed, 5 insertions(+), 35 deletions(-) diff --git a/redisinsight/api/src/modules/browser/services/set-business/set-business.service.spec.ts b/redisinsight/api/src/modules/browser/services/set-business/set-business.service.spec.ts index 29086fc600..a4969f12b6 100644 --- a/redisinsight/api/src/modules/browser/services/set-business/set-business.service.spec.ts +++ b/redisinsight/api/src/modules/browser/services/set-business/set-business.service.spec.ts @@ -12,7 +12,6 @@ import { mockRedisNoPermError, mockRedisWrongTypeError, mockBrowserClientMetadata, - mockDatabaseRecommendationService, } from 'src/__mocks__'; import { ReplyError } from 'src/models'; import { @@ -24,8 +23,6 @@ import { mockGetSetMembersDto, mockGetSetMembersResponse, mockSetMembers, } from 'src/modules/browser/__mocks__'; -import { DatabaseRecommendationService } from 'src/modules/database-recommendation/database-recommendation.service'; -import { RECOMMENDATION_NAMES } from 'src/constants'; import { SetBusinessService } from './set-business.service'; import { CreateSetWithExpireDto, @@ -39,7 +36,6 @@ nodeClient.isCluster = false; describe('SetBusinessService', () => { let service: SetBusinessService; let browserTool; - let recommendationService; beforeEach(async () => { jest.clearAllMocks(); @@ -51,16 +47,11 @@ describe('SetBusinessService', () => { provide: BrowserToolService, useFactory: mockRedisConsumer, }, - { - provide: DatabaseRecommendationService, - useFactory: mockDatabaseRecommendationService, - }, ], }).compile(); service = module.get(SetBusinessService); browserTool = module.get(BrowserToolService); - recommendationService = module.get(DatabaseRecommendationService); }); describe('createSet', () => { @@ -326,22 +317,6 @@ describe('SetBusinessService', () => { service.getMembers(mockBrowserClientMetadata, mockGetSetMembersDto), ).rejects.toThrow(ForbiddenException); }); - it('should call recommendationService', async () => { - when(browserTool.execCommand) - .calledWith( - mockBrowserClientMetadata, - BrowserToolSetCommands.SScan, - expect.anything(), - ) - .mockResolvedValue([Buffer.from('0'), mockSetMembers]); - - const result = await service.getMembers( - mockBrowserClientMetadata, - mockGetSetMembersDto, - ); - - expect(recommendationService.check).toBeCalledTimes(1); - }); }); describe('addMembers', () => { diff --git a/redisinsight/api/src/modules/browser/services/set-business/set-business.service.ts b/redisinsight/api/src/modules/browser/services/set-business/set-business.service.ts index 2dfffaf0ce..dde53b91ed 100644 --- a/redisinsight/api/src/modules/browser/services/set-business/set-business.service.ts +++ b/redisinsight/api/src/modules/browser/services/set-business/set-business.service.ts @@ -5,7 +5,7 @@ import { Logger, NotFoundException, } from '@nestjs/common'; -import { RECOMMENDATION_NAMES, RedisErrorCodes } from 'src/constants'; +import { RedisErrorCodes } from 'src/constants'; import ERROR_MESSAGES from 'src/constants/error-messages'; import config from 'src/utils/config'; import { @@ -17,7 +17,6 @@ import { BrowserToolKeysCommands, BrowserToolSetCommands, } from 'src/modules/browser/constants/browser-tool-commands'; -import { DatabaseRecommendationService } from 'src/modules/database-recommendation/database-recommendation.service'; import { plainToClass } from 'class-transformer'; import { AddMembersToSetDto, @@ -38,7 +37,6 @@ export class SetBusinessService { constructor( private browserTool: BrowserToolService, - private recommendationService: DatabaseRecommendationService, ) {} public async createSet( @@ -81,7 +79,6 @@ export class SetBusinessService { clientMetadata: ClientMetadata, dto: GetSetMembersDto, ): Promise { - const client = await this.browserTool.getRedisClient(clientMetadata); this.logger.log('Getting members of the Set data type stored at key.'); const { keyName } = dto; let result: GetSetMembersResponse = { diff --git a/redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.spec.ts b/redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.spec.ts index 689f44ab6d..a08b32fa51 100644 --- a/redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.spec.ts +++ b/redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.spec.ts @@ -9,7 +9,6 @@ import { SearchJSONStrategy, BigSetStrategy, RTSStrategy, - IntegersInSetStrategy, AvoidLogicalDatabasesStrategy, ShardHashStrategy, StringToJsonStrategy, diff --git a/redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.ts b/redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.ts index a0a30fa1d1..96ecaf6a1c 100644 --- a/redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.ts +++ b/redisinsight/api/src/modules/database-recommendation/scanner/recommendation.provider.ts @@ -9,7 +9,6 @@ import { SearchJSONStrategy, BigSetStrategy, RTSStrategy, - IntegersInSetStrategy, AvoidLogicalDatabasesStrategy, ShardHashStrategy, StringToJsonStrategy, diff --git a/redisinsight/api/src/modules/database-recommendation/scanner/strategies/big-set.strategy.spec.ts b/redisinsight/api/src/modules/database-recommendation/scanner/strategies/big-set.strategy.spec.ts index 866d74238b..873674c862 100644 --- a/redisinsight/api/src/modules/database-recommendation/scanner/strategies/big-set.strategy.spec.ts +++ b/redisinsight/api/src/modules/database-recommendation/scanner/strategies/big-set.strategy.spec.ts @@ -6,7 +6,7 @@ const mockSetInfo: GetKeyInfoResponse = { type: 'set', ttl: -1, size: 1, - length: 100_000, + length: 1_000, }; const mockBigSetInfo: GetKeyInfoResponse = { @@ -14,7 +14,7 @@ const mockBigSetInfo: GetKeyInfoResponse = { type: 'set', ttl: -1, size: 1, - length: 100_001, + length: 1_001, }; const mockHashInfo: GetKeyInfoResponse = { @@ -33,7 +33,7 @@ describe('BigSetStrategy', () => { }); describe('isRecommendationReached', () => { - it('should return false when set length < 100 000', async () => { + it('should return false when set length < 1 000', async () => { expect(await strategy.isRecommendationReached(mockSetInfo)).toEqual({ isReached: false }); }); @@ -41,7 +41,7 @@ describe('BigSetStrategy', () => { expect(await strategy.isRecommendationReached(mockHashInfo)).toEqual({ isReached: false }); }); - it('should return true when set length > 100 000', async () => { + it('should return true when set length > 1 000', async () => { expect(await strategy.isRecommendationReached(mockBigSetInfo)) .toEqual({ isReached: true, params: { keys: [mockBigSetInfo.name] } }); }); From 21794f2bb7a8ac986075230fb3fbadbef0314971 Mon Sep 17 00:00:00 2001 From: Amir Allayarov <100589048+AmirAllayarovSofteq@users.noreply.github.com> Date: Thu, 25 May 2023 11:03:56 +0300 Subject: [PATCH 4/4] Fe/feature/ri 4566 update recommendations static (#2130) * #RI-4566 - update text --- .../LiveTimeRecommendations.tsx | 6 +- .../welcome-screen/WelcomeScreen.tsx | 8 +- .../constants/dbAnalysisRecommendations.json | 317 ++++++++++++++++-- .../utils/recommendation/styles.module.scss | 1 + 4 files changed, 301 insertions(+), 31 deletions(-) diff --git a/redisinsight/ui/src/components/live-time-recommendations/LiveTimeRecommendations.tsx b/redisinsight/ui/src/components/live-time-recommendations/LiveTimeRecommendations.tsx index 07d8f4c816..2a441343be 100644 --- a/redisinsight/ui/src/components/live-time-recommendations/LiveTimeRecommendations.tsx +++ b/redisinsight/ui/src/components/live-time-recommendations/LiveTimeRecommendations.tsx @@ -221,10 +221,10 @@ const LiveTimeRecommendations = () => { <> Recommendations will help you improve your database.
- Work in the database to see new recommendations appeared on how to improve performance, - optimize memory usage, and enhance the performance of your database. + New recommendations appear while you work with your database, + including how to improve performance and optimize memory usage.
- Eager to see more recommendations? Run Database Analysis in order to see the magic happens. + Eager for more recommendations? Run Database Analysis to get started. )} > diff --git a/redisinsight/ui/src/components/live-time-recommendations/components/welcome-screen/WelcomeScreen.tsx b/redisinsight/ui/src/components/live-time-recommendations/components/welcome-screen/WelcomeScreen.tsx index c0ab9a61bf..0c232ff6ef 100644 --- a/redisinsight/ui/src/components/live-time-recommendations/components/welcome-screen/WelcomeScreen.tsx +++ b/redisinsight/ui/src/components/live-time-recommendations/components/welcome-screen/WelcomeScreen.tsx @@ -46,14 +46,14 @@ const NoRecommendationsScreen = () => {
Welcome to Insights! - Where we will help you improve your database. + Where we help improve your database. - Work in the database to see new recommendations appeared on how to improve performance, optimize memory usage, - and enhance the performance of your database. + New recommendations appear while you work with your database, + including how to improve performance and optimize memory usage. - Eager to see more recommendations? Run Database Analysis in order to see the magic happens. + Eager for more recommendations? Run Database Analysis to get started.