Skip to content

Commit b8ffd52

Browse files
authored
Merge pull request #1331 from RedisInsight/main
RC 2.12.0
2 parents 33ca869 + 0fcc236 commit b8ffd52

File tree

513 files changed

+16636
-5447
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

513 files changed

+16636
-5447
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ lerna-debug.log*
1616
# Tests
1717
/coverage
1818
/.nyc_output
19+
**/coverage
1920

2021
# IDEs and editors
2122
/.idea

jest.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ const { TextDecoder, TextEncoder } = require('util');
33
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
44
module.exports = {
55
testURL: 'http://localhost/',
6+
runner: 'groups',
67
moduleNameMapper: {
7-
'\\.(jpg|jpeg|png|ico|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
8+
'\\.(jpg|jpeg|png|ico|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
89
'<rootDir>/redisinsight/__mocks__/fileMock.js',
10+
'\\.svg': '<rootDir>/redisinsight/__mocks__/svg.js',
911
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
1012
'uiSrc/(.*)': '<rootDir>/redisinsight/ui/src/$1',
1113
'monaco-editor': '<rootDir>/redisinsight/__mocks__/monacoMock.js',
@@ -44,6 +46,12 @@ module.exports = {
4446
'<rootDir>/redisinsight/ui/src/packages',
4547
'<rootDir>/redisinsight/ui/src/mocks',
4648
],
49+
coverageDirectory: './coverage',
50+
coveragePathIgnorePatterns: [
51+
'/node_modules/',
52+
'<rootDir>/redisinsight/api',
53+
'<rootDir>/redisinsight/ui/src/packages',
54+
],
4755
coverageThreshold: {
4856
global: {
4957
statements: 70,

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
"test": "jest ./redisinsight/ui -w 1",
4040
"test:watch": "jest ./redisinsight/ui --watch -w 1",
4141
"test:cov": "jest ./redisinsight/ui --coverage -w 1",
42+
"test:cov:unit": "jest ./redisinsight/ui --group=-component --coverage -w 1",
43+
"test:cov:component": "jest ./redisinsight/ui --group=component --coverage -w 1",
4244
"type-check:ui": "tsc --project redisinsight/ui --noEmit"
4345
},
4446
"lint-staged": {
@@ -173,6 +175,7 @@
173175
"ioredis-mock": "^5.5.4",
174176
"ip": "^1.1.8",
175177
"jest": "^27.5.1",
178+
"jest-runner-groups": "^2.2.0",
176179
"jest-when": "^3.2.1",
177180
"lint-staged": "^10.2.11",
178181
"mini-css-extract-plugin": "^1.3.1",

redisinsight/__mocks__/svg.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export default 'SvgrURL'
2+
export const ReactComponent = 'div'

redisinsight/api/config/default.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ export default {
140140
unsupportedCommands: JSON.parse(process.env.WORKBENCH_UNSUPPORTED_COMMANDS || '[]'),
141141
countBatch: parseInt(process.env.WORKBENCH_BATCH_SIZE, 10) || 5,
142142
},
143+
database_analysis: {
144+
maxItemsPerDb: parseInt(process.env.DATABASE_ANALYSIS_MAX_ITEMS_PER_DB, 10) || 5,
145+
},
143146
commands: [
144147
{
145148
name: 'main',

redisinsight/api/config/ormconfig.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ import { SettingsEntity } from 'src/modules/core/models/settings.entity';
88
import { CommandExecutionEntity } from 'src/modules/workbench/entities/command-execution.entity';
99
import { PluginStateEntity } from 'src/modules/workbench/entities/plugin-state.entity';
1010
import { NotificationEntity } from 'src/modules/notification/entities/notification.entity';
11+
import { DatabaseAnalysisEntity } from 'src/modules/database-analysis/entities/database-analysis.entity';
12+
import { DataSource } from 'typeorm';
1113
import migrations from '../migration';
1214
import * as config from '../src/utils/config';
1315

1416
const dbConfig = config.get('db');
15-
const ormConfig: TypeOrmModuleOptions = {
17+
18+
const ormConfig = {
1619
type: 'sqlite',
1720
database: dbConfig.database,
1821
synchronize: dbConfig.synchronize,
@@ -27,8 +30,10 @@ const ormConfig: TypeOrmModuleOptions = {
2730
CommandExecutionEntity,
2831
PluginStateEntity,
2932
NotificationEntity,
33+
DatabaseAnalysisEntity,
3034
],
3135
migrations,
3236
};
3337

34-
export default ormConfig;
38+
export const ormModuleOptions: TypeOrmModuleOptions = ormConfig as TypeOrmModuleOptions;
39+
export default new DataSource({ ...ormConfig, type: 'sqlite' });
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { MigrationInterface, QueryRunner } from "typeorm";
2+
3+
export class databaseAnalysis1664785208236 implements MigrationInterface {
4+
name = 'databaseAnalysis1664785208236'
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`CREATE TABLE "database_analysis" ("id" varchar PRIMARY KEY NOT NULL, "databaseId" varchar NOT NULL, "filter" blob, "delimiter" varchar NOT NULL, "progress" blob, "totalKeys" blob, "totalMemory" blob, "topKeysNsp" blob, "topMemoryNsp" blob, "topKeysLength" blob, "topKeysMemory" blob, "encryption" varchar, "createdAt" datetime NOT NULL DEFAULT (datetime('now')))`);
8+
await queryRunner.query(`CREATE INDEX "IDX_d174a8edc2201d6c5781f0126a" ON "database_analysis" ("databaseId") `);
9+
await queryRunner.query(`CREATE INDEX "IDX_fdd0daeb4d8f226cf1ff79bebb" ON "database_analysis" ("createdAt") `);
10+
await queryRunner.query(`DROP INDEX "IDX_d174a8edc2201d6c5781f0126a"`);
11+
await queryRunner.query(`DROP INDEX "IDX_fdd0daeb4d8f226cf1ff79bebb"`);
12+
await queryRunner.query(`CREATE TABLE "temporary_database_analysis" ("id" varchar PRIMARY KEY NOT NULL, "databaseId" varchar NOT NULL, "filter" blob, "delimiter" varchar NOT NULL, "progress" blob, "totalKeys" blob, "totalMemory" blob, "topKeysNsp" blob, "topMemoryNsp" blob, "topKeysLength" blob, "topKeysMemory" blob, "encryption" varchar, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_d174a8edc2201d6c5781f0126ae" FOREIGN KEY ("databaseId") REFERENCES "database_instance" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
13+
await queryRunner.query(`INSERT INTO "temporary_database_analysis"("id", "databaseId", "filter", "delimiter", "progress", "totalKeys", "totalMemory", "topKeysNsp", "topMemoryNsp", "topKeysLength", "topKeysMemory", "encryption", "createdAt") SELECT "id", "databaseId", "filter", "delimiter", "progress", "totalKeys", "totalMemory", "topKeysNsp", "topMemoryNsp", "topKeysLength", "topKeysMemory", "encryption", "createdAt" FROM "database_analysis"`);
14+
await queryRunner.query(`DROP TABLE "database_analysis"`);
15+
await queryRunner.query(`ALTER TABLE "temporary_database_analysis" RENAME TO "database_analysis"`);
16+
await queryRunner.query(`CREATE INDEX "IDX_d174a8edc2201d6c5781f0126a" ON "database_analysis" ("databaseId") `);
17+
await queryRunner.query(`CREATE INDEX "IDX_fdd0daeb4d8f226cf1ff79bebb" ON "database_analysis" ("createdAt") `);
18+
}
19+
20+
public async down(queryRunner: QueryRunner): Promise<void> {
21+
await queryRunner.query(`DROP INDEX "IDX_fdd0daeb4d8f226cf1ff79bebb"`);
22+
await queryRunner.query(`DROP INDEX "IDX_d174a8edc2201d6c5781f0126a"`);
23+
await queryRunner.query(`ALTER TABLE "database_analysis" RENAME TO "temporary_database_analysis"`);
24+
await queryRunner.query(`CREATE TABLE "database_analysis" ("id" varchar PRIMARY KEY NOT NULL, "databaseId" varchar NOT NULL, "filter" blob, "delimiter" varchar NOT NULL, "progress" blob, "totalKeys" blob, "totalMemory" blob, "topKeysNsp" blob, "topMemoryNsp" blob, "topKeysLength" blob, "topKeysMemory" blob, "encryption" varchar, "createdAt" datetime NOT NULL DEFAULT (datetime('now')))`);
25+
await queryRunner.query(`INSERT INTO "database_analysis"("id", "databaseId", "filter", "delimiter", "progress", "totalKeys", "totalMemory", "topKeysNsp", "topMemoryNsp", "topKeysLength", "topKeysMemory", "encryption", "createdAt") SELECT "id", "databaseId", "filter", "delimiter", "progress", "totalKeys", "totalMemory", "topKeysNsp", "topMemoryNsp", "topKeysLength", "topKeysMemory", "encryption", "createdAt" FROM "temporary_database_analysis"`);
26+
await queryRunner.query(`DROP TABLE "temporary_database_analysis"`);
27+
await queryRunner.query(`CREATE INDEX "IDX_fdd0daeb4d8f226cf1ff79bebb" ON "database_analysis" ("createdAt") `);
28+
await queryRunner.query(`CREATE INDEX "IDX_d174a8edc2201d6c5781f0126a" ON "database_analysis" ("databaseId") `);
29+
await queryRunner.query(`DROP INDEX "IDX_fdd0daeb4d8f226cf1ff79bebb"`);
30+
await queryRunner.query(`DROP INDEX "IDX_d174a8edc2201d6c5781f0126a"`);
31+
await queryRunner.query(`DROP TABLE "database_analysis"`);
32+
}
33+
34+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { MigrationInterface, QueryRunner } from "typeorm";
2+
3+
export class databaseAnalysisExpirationGroups1664886479051 implements MigrationInterface {
4+
name = 'databaseAnalysisExpirationGroups1664886479051'
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`DROP INDEX "IDX_fdd0daeb4d8f226cf1ff79bebb"`);
8+
await queryRunner.query(`DROP INDEX "IDX_d174a8edc2201d6c5781f0126a"`);
9+
await queryRunner.query(`CREATE TABLE "temporary_database_analysis" ("id" varchar PRIMARY KEY NOT NULL, "databaseId" varchar NOT NULL, "filter" blob, "delimiter" varchar NOT NULL, "progress" blob, "totalKeys" blob, "totalMemory" blob, "topKeysNsp" blob, "topMemoryNsp" blob, "topKeysLength" blob, "topKeysMemory" blob, "encryption" varchar, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "expirationGroups" blob, CONSTRAINT "FK_d174a8edc2201d6c5781f0126ae" FOREIGN KEY ("databaseId") REFERENCES "database_instance" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
10+
await queryRunner.query(`INSERT INTO "temporary_database_analysis"("id", "databaseId", "filter", "delimiter", "progress", "totalKeys", "totalMemory", "topKeysNsp", "topMemoryNsp", "topKeysLength", "topKeysMemory", "encryption", "createdAt") SELECT "id", "databaseId", "filter", "delimiter", "progress", "totalKeys", "totalMemory", "topKeysNsp", "topMemoryNsp", "topKeysLength", "topKeysMemory", "encryption", "createdAt" FROM "database_analysis"`);
11+
await queryRunner.query(`DROP TABLE "database_analysis"`);
12+
await queryRunner.query(`ALTER TABLE "temporary_database_analysis" RENAME TO "database_analysis"`);
13+
await queryRunner.query(`CREATE INDEX "IDX_fdd0daeb4d8f226cf1ff79bebb" ON "database_analysis" ("createdAt") `);
14+
await queryRunner.query(`CREATE INDEX "IDX_d174a8edc2201d6c5781f0126a" ON "database_analysis" ("databaseId") `);
15+
}
16+
17+
public async down(queryRunner: QueryRunner): Promise<void> {
18+
await queryRunner.query(`DROP INDEX "IDX_d174a8edc2201d6c5781f0126a"`);
19+
await queryRunner.query(`DROP INDEX "IDX_fdd0daeb4d8f226cf1ff79bebb"`);
20+
await queryRunner.query(`ALTER TABLE "database_analysis" RENAME TO "temporary_database_analysis"`);
21+
await queryRunner.query(`CREATE TABLE "database_analysis" ("id" varchar PRIMARY KEY NOT NULL, "databaseId" varchar NOT NULL, "filter" blob, "delimiter" varchar NOT NULL, "progress" blob, "totalKeys" blob, "totalMemory" blob, "topKeysNsp" blob, "topMemoryNsp" blob, "topKeysLength" blob, "topKeysMemory" blob, "encryption" varchar, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_d174a8edc2201d6c5781f0126ae" FOREIGN KEY ("databaseId") REFERENCES "database_instance" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
22+
await queryRunner.query(`INSERT INTO "database_analysis"("id", "databaseId", "filter", "delimiter", "progress", "totalKeys", "totalMemory", "topKeysNsp", "topMemoryNsp", "topKeysLength", "topKeysMemory", "encryption", "createdAt") SELECT "id", "databaseId", "filter", "delimiter", "progress", "totalKeys", "totalMemory", "topKeysNsp", "topMemoryNsp", "topKeysLength", "topKeysMemory", "encryption", "createdAt" FROM "temporary_database_analysis"`);
23+
await queryRunner.query(`DROP TABLE "temporary_database_analysis"`);
24+
await queryRunner.query(`CREATE INDEX "IDX_d174a8edc2201d6c5781f0126a" ON "database_analysis" ("databaseId") `);
25+
await queryRunner.query(`CREATE INDEX "IDX_fdd0daeb4d8f226cf1ff79bebb" ON "database_analysis" ("createdAt") `);
26+
}
27+
28+
}

redisinsight/api/migration/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { notification1655821010349 } from './1655821010349-notification';
1717
import { notificationCategory1659687030433 } from './1659687030433-notification-category';
1818
import { workbenchMode1660664717573 } from './1660664717573-workbench-mode';
1919
import { workbenchGroupMode1663093411715 } from './1663093411715-workbench-group-mode';
20+
import { databaseAnalysis1664785208236 } from './1664785208236-database-analysis';
21+
import { databaseAnalysisExpirationGroups1664886479051 } from './1664886479051-database-analysis-expiration-groups';
2022

2123
export default [
2224
initialMigration1614164490968,
@@ -38,4 +40,6 @@ export default [
3840
notificationCategory1659687030433,
3941
workbenchMode1660664717573,
4042
workbenchGroupMode1663093411715,
43+
databaseAnalysis1664785208236,
44+
databaseAnalysisExpirationGroups1664886479051,
4145
];

redisinsight/api/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
"test:cov": "cross-env NODE_ENV=test ./node_modules/.bin/jest --coverage -w 1",
3131
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand -w 1",
3232
"test:e2e": "jest --config ./test/jest-e2e.json -w 1",
33-
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config ./config/ormconfig.ts",
33+
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -d ./config/ormconfig.ts",
3434
"test:api": "ts-mocha --paths -p test/api/api.tsconfig.json --config ./test/api/.mocharc.yml",
3535
"test:api:cov": "nyc --reporter=html --reporter=text --reporter=text-summary yarn run test:api",
36-
"test:api:ci:cov": "nyc -r text -r text-summary yarn run test:api --reporter mocha-multi-reporters --reporter-options configFile=test/api/reporters.json && nyc merge .nyc_output ./coverage/test-run-coverage.json",
37-
"typeorm:migrate": "cross-env NODE_ENV=production yarn typeorm migration:generate -- -n migration",
36+
"test:api:ci:cov": "nyc -r text -r text-summary -r html yarn run test:api --reporter mocha-multi-reporters --reporter-options configFile=test/api/reporters.json && nyc merge .nyc_output ./coverage/test-run-coverage.json",
37+
"typeorm:migrate": "cross-env NODE_ENV=production yarn typeorm migration:generate ./migration/migration",
3838
"typeorm:run": "yarn typeorm migration:run"
3939
},
4040
"dependencies": {

0 commit comments

Comments
 (0)