Skip to content

Commit 4053a5f

Browse files
authored
Merge pull request #3553 from RedisInsight/feature/RI-5681-search-and-query
Feature/ri 5681 search and query
2 parents 1e99314 + 8ae91a2 commit 4053a5f

File tree

233 files changed

+9343
-1459
lines changed

Some content is hidden

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

233 files changed

+9343
-1459
lines changed

redisinsight/__mocks__/monacoMock.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ const editor = {
1515
executeEdits: jest.fn(),
1616
updateOptions: jest.fn(),
1717
setSelection: jest.fn(),
18+
setPosition: jest.fn(),
1819
createDecorationsCollection: jest.fn(),
1920
getValue: jest.fn().mockReturnValue(''),
20-
getModel: jest.fn().mockReturnValue({}),
21-
getPosition: jest.fn(),
21+
getModel: jest.fn().mockReturnValue({
22+
getOffsetAt: jest.fn().mockReturnValue(0),
23+
getWordUntilPosition: jest.fn().mockReturnValue(''),
24+
}),
25+
getPosition: jest.fn().mockReturnValue({}),
2226
trigger: jest.fn(),
2327
}
2428

@@ -70,16 +74,18 @@ export const languages = {
7074
},
7175
CompletionItemInsertTextRule: {
7276
InsertAsSnippet: 4
73-
}
77+
},
78+
...monacoEditor.languages
7479
}
7580

7681
export const monaco = {
7782
languages,
7883
Selection: jest.fn().mockImplementation(() => ({})),
7984
editor: {
85+
...editor,
8086
colorize: jest.fn().mockImplementation((data) => Promise.resolve(data)),
8187
defineTheme: jest.fn(),
82-
setTheme: jest.fn()
88+
setTheme: jest.fn(),
8389
},
8490
Range: monacoEditor.Range
8591
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { MigrationInterface, QueryRunner } from "typeorm";
2+
3+
export class CommandExecution1726058563737 implements MigrationInterface {
4+
name = 'CommandExecution1726058563737'
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`DROP INDEX "IDX_5cd90dd6def1fd7c521e53fb2c"`);
8+
await queryRunner.query(`CREATE TABLE "temporary_command_execution" ("id" varchar PRIMARY KEY NOT NULL, "databaseId" varchar NOT NULL, "command" text NOT NULL, "result" text NOT NULL, "role" varchar, "nodeOptions" varchar, "encryption" varchar, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "mode" varchar, "resultsMode" varchar, "summary" varchar, "executionTime" integer, "db" integer, "type" varchar NOT NULL DEFAULT ('WORKBENCH'), CONSTRAINT "FK_ea8adfe9aceceb79212142206b8" FOREIGN KEY ("databaseId") REFERENCES "database_instance" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
9+
await queryRunner.query(`INSERT INTO "temporary_command_execution"("id", "databaseId", "command", "result", "role", "nodeOptions", "encryption", "createdAt", "mode", "resultsMode", "summary", "executionTime", "db") SELECT "id", "databaseId", "command", "result", "role", "nodeOptions", "encryption", "createdAt", "mode", "resultsMode", "summary", "executionTime", "db" FROM "command_execution"`);
10+
await queryRunner.query(`DROP TABLE "command_execution"`);
11+
await queryRunner.query(`ALTER TABLE "temporary_command_execution" RENAME TO "command_execution"`);
12+
await queryRunner.query(`CREATE INDEX "IDX_5cd90dd6def1fd7c521e53fb2c" ON "command_execution" ("createdAt") `);
13+
}
14+
15+
public async down(queryRunner: QueryRunner): Promise<void> {
16+
await queryRunner.query(`DROP INDEX "IDX_5cd90dd6def1fd7c521e53fb2c"`);
17+
await queryRunner.query(`ALTER TABLE "command_execution" RENAME TO "temporary_command_execution"`);
18+
await queryRunner.query(`CREATE TABLE "command_execution" ("id" varchar PRIMARY KEY NOT NULL, "databaseId" varchar NOT NULL, "command" text NOT NULL, "result" text NOT NULL, "role" varchar, "nodeOptions" varchar, "encryption" varchar, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "mode" varchar, "resultsMode" varchar, "summary" varchar, "executionTime" integer, "db" integer, CONSTRAINT "FK_ea8adfe9aceceb79212142206b8" FOREIGN KEY ("databaseId") REFERENCES "database_instance" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`);
19+
await queryRunner.query(`INSERT INTO "command_execution"("id", "databaseId", "command", "result", "role", "nodeOptions", "encryption", "createdAt", "mode", "resultsMode", "summary", "executionTime", "db") SELECT "id", "databaseId", "command", "result", "role", "nodeOptions", "encryption", "createdAt", "mode", "resultsMode", "summary", "executionTime", "db" FROM "temporary_command_execution"`);
20+
await queryRunner.query(`DROP TABLE "temporary_command_execution"`);
21+
await queryRunner.query(`CREATE INDEX "IDX_5cd90dd6def1fd7c521e53fb2c" ON "command_execution" ("createdAt") `);
22+
}
23+
24+
}

redisinsight/api/migration/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { AiHistory1713515657364 } from './1713515657364-ai-history';
4242
import { AiHistorySteps1714501203616 } from './1714501203616-ai-history-steps';
4343
import { Rdi1716370509836 } from './1716370509836-rdi';
4444
import { AiHistory1718260230164 } from './1718260230164-ai-history';
45+
import { CommandExecution1726058563737 } from './1726058563737-command-execution';
4546

4647
export default [
4748
initialMigration1614164490968,
@@ -88,4 +89,5 @@ export default [
8889
AiHistorySteps1714501203616,
8990
Rdi1716370509836,
9091
AiHistory1718260230164,
92+
CommandExecution1726058563737,
9193
];

redisinsight/api/src/__mocks__/common.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type MockType<T> = {
88
};
99

1010
export const mockQueryBuilderWhere = jest.fn().mockReturnThis();
11+
export const mockQueryBuilderWhereInIds = jest.fn().mockReturnThis();
1112
export const mockQueryBuilderSelect = jest.fn().mockReturnThis();
1213
export const mockQueryBuilderLeftJoinAndSelect = jest.fn().mockReturnThis();
1314
export const mockQueryBuilderGetOne = jest.fn();
@@ -18,6 +19,7 @@ export const mockQueryBuilderExecute = jest.fn();
1819
export const mockCreateQueryBuilder = jest.fn(() => ({
1920
// where: jest.fn().mockReturnThis(),
2021
where: mockQueryBuilderWhere,
22+
whereInIds: mockQueryBuilderWhereInIds,
2123
orWhere: mockQueryBuilderWhere,
2224
update: jest.fn().mockReturnThis(),
2325
select: mockQueryBuilderSelect,
@@ -30,7 +32,6 @@ export const mockCreateQueryBuilder = jest.fn(() => ({
3032
leftJoinAndSelect: mockQueryBuilderLeftJoinAndSelect,
3133
offset: jest.fn().mockReturnThis(),
3234
delete: jest.fn().mockReturnThis(),
33-
whereInIds: jest.fn().mockReturnThis(),
3435
execute: mockQueryBuilderExecute,
3536
getCount: mockQueryBuilderGetCount,
3637
getRawMany: mockQueryBuilderGetManyRaw,

redisinsight/api/src/__mocks__/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ export * from './cloud-session';
4141
export * from './database-info';
4242
export * from './cloud-job';
4343
export * from './rdi';
44+
export * from './workbench';
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
import { IndexInfoDto } from 'src/modules/browser/redisearch/dto';
2+
3+
export const mockIndexInfoRaw = [
4+
'index_name',
5+
'idx:movie',
6+
'index_options',
7+
[],
8+
'index_definition',
9+
['key_type', 'HASH', 'prefixes', ['movie:'], 'default_score', '1'],
10+
'attributes',
11+
[
12+
['identifier', 'title', 'attribute', 'title', 'type', 'TEXT', 'WEIGHT', '1', 'SORTABLE'],
13+
['identifier', 'release_year', 'attribute', 'release_year', 'type', 'NUMERIC', 'SORTABLE', 'UNF'],
14+
['identifier', 'rating', 'attribute', 'rating', 'type', 'NUMERIC', 'SORTABLE', 'UNF'],
15+
['identifier', 'genre', 'attribute', 'genre', 'type', 'TAG', 'SEPARATOR', ',', 'SORTABLE'],
16+
],
17+
'num_docs',
18+
'2',
19+
'max_doc_id',
20+
'2',
21+
'num_terms',
22+
'13',
23+
'num_records',
24+
'19',
25+
'inverted_sz_mb',
26+
'0.0016384124755859375',
27+
'vector_index_sz_mb',
28+
'0',
29+
'total_inverted_index_blocks',
30+
'17',
31+
'offset_vectors_sz_mb',
32+
'1.239776611328125e-5',
33+
'doc_table_size_mb',
34+
'1.468658447265625e-4',
35+
'sortable_values_size_mb',
36+
'2.498626708984375e-4',
37+
'key_table_size_mb',
38+
'8.296966552734375e-5',
39+
'tag_overhead_sz_mb',
40+
'5.53131103515625e-5',
41+
'text_overhead_sz_mb',
42+
'4.3392181396484375e-4',
43+
'total_index_memory_sz_mb',
44+
'0.0026903152465820313',
45+
'geoshapes_sz_mb', '0',
46+
'records_per_doc_avg',
47+
'9.5',
48+
'bytes_per_record_avg',
49+
'90.42105102539063',
50+
'offsets_per_term_avg',
51+
'0.6842105388641357',
52+
'offset_bits_per_record_avg',
53+
'8', 'hash_indexing_failures',
54+
'0', 'total_indexing_time', '0.890999972820282', 'indexing', '0',
55+
'percent_indexed', '1', 'number_of_uses', 17, 'cleaning', 0, 'gc_stats',
56+
['bytes_collected', '0', 'total_ms_run', '0', 'total_cycles', '0',
57+
'average_cycle_time_ms', 'nan', 'last_run_time_ms', '0',
58+
'gc_numeric_trees_missed', '0', 'gc_blocks_denied', '0',
59+
],
60+
'cursor_stats',
61+
['global_idle', 0, 'global_total', 0, 'index_capacity', 128, 'index_total', 0],
62+
'dialect_stats',
63+
['dialect_1', 1, 'dialect_2', 0, 'dialect_3', 0, 'dialect_4', 0],
64+
'Index Errors',
65+
['indexing failures', 0, 'last indexing error', 'N/A', 'last indexing error key', 'N/A'],
66+
'field statistics',
67+
[
68+
['identifier', 'title', 'attribute', 'title', 'Index Errors',
69+
['indexing failures', 0, 'last indexing error', 'N/A', 'last indexing error key', 'N/A'],
70+
],
71+
['identifier', 'release_year', 'attribute', 'release_year', 'Index Errors',
72+
['indexing failures', 0, 'last indexing error', 'N/A', 'last indexing error key', 'N/A'],
73+
],
74+
['identifier', 'rating', 'attribute', 'rating', 'Index Errors',
75+
['indexing failures', 0, 'last indexing error', 'N/A', 'last indexing error key', 'N/A'],
76+
],
77+
['identifier', 'genre', 'attribute', 'genre', 'Index Errors',
78+
['indexing failures', 0, 'last indexing error', 'N/A', 'last indexing error key', 'N/A'],
79+
]]];
80+
81+
export const mockIndexInfoDto: IndexInfoDto = {
82+
index_name: 'idx:movie',
83+
index_options: {},
84+
index_definition: { key_type: 'HASH', prefixes: ['movie:'], default_score: '1' },
85+
attributes: [
86+
{
87+
identifier: 'title',
88+
attribute: 'title',
89+
type: 'TEXT',
90+
WEIGHT: '1',
91+
SORTABLE: true,
92+
NOINDEX: undefined,
93+
CASESENSITIVE: undefined,
94+
UNF: undefined,
95+
NOSTEM: undefined,
96+
},
97+
{
98+
identifier: 'release_year',
99+
attribute: 'release_year',
100+
type: 'NUMERIC',
101+
SORTABLE: true,
102+
NOINDEX: undefined,
103+
CASESENSITIVE: undefined,
104+
UNF: true,
105+
NOSTEM: undefined,
106+
},
107+
{
108+
identifier: 'rating',
109+
attribute: 'rating',
110+
type: 'NUMERIC',
111+
SORTABLE: true,
112+
NOINDEX: undefined,
113+
CASESENSITIVE: undefined,
114+
UNF: true,
115+
NOSTEM: undefined,
116+
},
117+
{
118+
identifier: 'genre',
119+
attribute: 'genre',
120+
type: 'TAG',
121+
SEPARATOR: ',',
122+
SORTABLE: true,
123+
NOINDEX: undefined,
124+
CASESENSITIVE: undefined,
125+
UNF: undefined,
126+
NOSTEM: undefined,
127+
},
128+
],
129+
num_docs: '2',
130+
max_doc_id: '2',
131+
num_terms: '13',
132+
num_records: '19',
133+
inverted_sz_mb: '0.0016384124755859375',
134+
vector_index_sz_mb: '0',
135+
total_inverted_index_blocks: '17',
136+
offset_vectors_sz_mb: '1.239776611328125e-5',
137+
doc_table_size_mb: '1.468658447265625e-4',
138+
sortable_values_size_mb: '2.498626708984375e-4',
139+
tag_overhead_sz_mb: '5.53131103515625e-5',
140+
text_overhead_sz_mb: '4.3392181396484375e-4',
141+
total_index_memory_sz_mb: '0.0026903152465820313',
142+
143+
key_table_size_mb: '8.296966552734375e-5',
144+
geoshapes_sz_mb: '0',
145+
records_per_doc_avg: '9.5',
146+
bytes_per_record_avg: '90.42105102539063',
147+
offsets_per_term_avg: '0.6842105388641357',
148+
offset_bits_per_record_avg: '8',
149+
hash_indexing_failures: '0',
150+
total_indexing_time: '0.890999972820282',
151+
indexing: '0',
152+
percent_indexed: '1',
153+
number_of_uses: 17,
154+
cleaning: 0,
155+
gc_stats: {
156+
bytes_collected: '0',
157+
total_ms_run: '0',
158+
total_cycles: '0',
159+
average_cycle_time_ms: 'nan',
160+
last_run_time_ms: '0',
161+
gc_numeric_trees_missed: '0',
162+
gc_blocks_denied: '0',
163+
},
164+
cursor_stats: {
165+
global_idle: 0,
166+
global_total: 0,
167+
index_capacity: 128,
168+
index_total: 0,
169+
},
170+
dialect_stats: {
171+
dialect_1: 1, dialect_2: 0, dialect_3: 0, dialect_4: 0,
172+
},
173+
'Index Errors': {
174+
'indexing failures': 0,
175+
'last indexing error': 'N/A',
176+
'last indexing error key': 'N/A',
177+
},
178+
'field statistics': [
179+
{
180+
identifier: 'title',
181+
attribute: 'title',
182+
'Index Errors': {
183+
'indexing failures': 0,
184+
'last indexing error': 'N/A',
185+
'last indexing error key': 'N/A',
186+
},
187+
},
188+
{
189+
identifier: 'release_year',
190+
attribute: 'release_year',
191+
'Index Errors': {
192+
'indexing failures': 0,
193+
'last indexing error': 'N/A',
194+
'last indexing error key': 'N/A',
195+
},
196+
},
197+
{
198+
identifier: 'rating',
199+
attribute: 'rating',
200+
'Index Errors': {
201+
'indexing failures': 0,
202+
'last indexing error': 'N/A',
203+
'last indexing error key': 'N/A',
204+
},
205+
},
206+
{
207+
identifier: 'genre',
208+
attribute: 'genre',
209+
'Index Errors': {
210+
'indexing failures': 0,
211+
'last indexing error': 'N/A',
212+
'last indexing error key': 'N/A',
213+
},
214+
},
215+
],
216+
};

0 commit comments

Comments
 (0)