Skip to content

Commit 0104b41

Browse files
committed
Allow redisearch module to show aggregate profile results as well
1 parent 6420582 commit 0104b41

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

redisinsight/ui/src/packages/redisearch/src/App.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
parseSearchRawResponse,
1010
parseAggregateRawResponse
1111
} from './utils'
12-
import { Command } from './constants'
12+
import { Command, ProfileType } from './constants'
1313
import { TableInfoResult, TableResult } from './components'
1414

1515
interface Props {
@@ -35,16 +35,25 @@ const App = (props: Props) => {
3535
return <TableInfoResult query={command} result={result} />
3636
}
3737

38-
if (commandUpper.startsWith(Command.Aggregate)) {
39-
const [matched, ...arrayResponse] = response
38+
const isProfileCommand = commandUpper.startsWith(Command.Profile)
39+
const profileQueryType = command?.split(' ')?.[2]
40+
41+
if (
42+
commandUpper.startsWith(Command.Aggregate)
43+
|| (isProfileCommand && profileQueryType.toUpperCase() === ProfileType.Aggregate)
44+
) {
45+
const [matched, ...arrayResponse] = isProfileCommand ? response[0] : response
4046
setHeaderText(`Matched:${matched}`)
4147

4248
const result = parseAggregateRawResponse(arrayResponse)
4349
return <TableResult query={command} result={result} matched={matched} />
4450
}
4551

46-
if (commandUpper.startsWith(Command.Search) || commandUpper.startsWith(Command.Profile)) {
47-
const [matched, ...arrayResponse] = commandUpper.startsWith(Command.Profile) ? response[0] : response
52+
if (
53+
commandUpper.startsWith(Command.Search)
54+
|| (isProfileCommand && profileQueryType.toUpperCase() === ProfileType.Search)
55+
) {
56+
const [matched, ...arrayResponse] = isProfileCommand ? response[0] : response
4857
setHeaderText(`Matched:${matched}`)
4958

5059
const result = parseSearchRawResponse(command, arrayResponse)

redisinsight/ui/src/packages/redisearch/src/constants/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ export enum Command {
77
Profile = 'FT.PROFILE',
88
}
99

10+
export enum ProfileType {
11+
Search = 'SEARCH',
12+
Aggregate = 'AGGREGATE',
13+
}
14+
1015
export enum CommandArgument {
1116
NoContent = 'NOCONTENT',
1217
Return = 'RETURN',

0 commit comments

Comments
 (0)