Skip to content

Commit ed81743

Browse files
fix: use relative paths, remove unused conditions
1 parent 59f2ae3 commit ed81743

File tree

7 files changed

+23
-34
lines changed

7 files changed

+23
-34
lines changed

src/store/reducers/cluster/cluster.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const clusterApi = api.injectEndpoints({
8787
}
8888

8989
try {
90-
const query = createSelectClusterGroupsQuery(clusterRoot);
90+
const query = createSelectClusterGroupsQuery();
9191

9292
// Normally query request should be fulfilled within 300-400ms even on very big clusters
9393
// Table with stats is supposed to be very small (less than 10 rows)

src/store/reducers/cluster/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {parseQueryAPIResponse} from '../../../utils/query';
55

66
import type {ClusterGroupsStats} from './types';
77

8-
export const createSelectClusterGroupsQuery = (clusterRoot: string) => {
8+
export const createSelectClusterGroupsQuery = () => {
99
return `${QUERY_TECHNICAL_MARK}
1010
SELECT
1111
PDiskFilter,
@@ -14,7 +14,7 @@ SELECT
1414
CurrentAllocatedSize,
1515
CurrentGroupsCreated,
1616
AvailableGroupsToCreate
17-
FROM \`${clusterRoot}/.sys/ds_storage_stats\`
17+
FROM \`.sys/ds_storage_stats\`
1818
ORDER BY CurrentGroupsCreated DESC;
1919
`;
2020
};

src/store/reducers/executeTopQueries/executeTopQueries.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const slice = createSlice({
2626
export const {setTopQueriesFilters} = slice.actions;
2727
export default slice.reducer;
2828

29-
const getQueryText = (database: string, filters?: TopQueriesFilters, sortOrder?: SortOrder[]) => {
30-
const filterConditions = getFiltersConditions(database, filters);
29+
const getQueryText = (filters?: TopQueriesFilters, sortOrder?: SortOrder[]) => {
30+
const filterConditions = getFiltersConditions(filters);
3131

3232
const orderBy = prepareOrderByFromTableSort(sortOrder);
3333

@@ -41,18 +41,14 @@ SELECT
4141
ReadBytes,
4242
UserSID,
4343
Duration
44-
FROM \`${database}/.sys/top_queries_by_cpu_time_one_hour\`
44+
FROM \`.sys/top_queries_by_cpu_time_one_hour\`
4545
WHERE ${filterConditions || 'true'} AND QueryText NOT LIKE '%${QUERY_TECHNICAL_MARK}%'
4646
${orderBy}
4747
LIMIT 100
4848
`;
4949
};
5050

51-
function getRunningQueriesText(
52-
database: string,
53-
filters?: TopQueriesFilters,
54-
sortOrder?: SortOrder[],
55-
) {
51+
function getRunningQueriesText(filters?: TopQueriesFilters, sortOrder?: SortOrder[]) {
5652
const filterConditions = filters?.text
5753
? `Query ILIKE '%${filters.text}%' OR UserSID ILIKE '%${filters.text}%'`
5854
: '';
@@ -65,7 +61,7 @@ SELECT
6561
QueryStartAt,
6662
Query as QueryText,
6763
ApplicationName
68-
FROM \`${database}/.sys/query_sessions\`
64+
FROM \`.sys/query_sessions\`
6965
WHERE ${filterConditions || 'true'} AND Query NOT LIKE '%${QUERY_TECHNICAL_MARK}%'
7066
${orderBy}
7167
LIMIT 100`;
@@ -90,7 +86,7 @@ export const topQueriesApi = api.injectEndpoints({
9086
try {
9187
const response = await window.api.viewer.sendQuery(
9288
{
93-
query: getQueryText(database, preparedFilters, sortOrder),
89+
query: getQueryText(preparedFilters, sortOrder),
9490
database,
9591
action: 'execute-scan',
9692
},
@@ -126,7 +122,7 @@ export const topQueriesApi = api.injectEndpoints({
126122
try {
127123
const response = await window.api.viewer.sendQuery(
128124
{
129-
query: getRunningQueriesText(database, filters, sortOrder),
125+
query: getRunningQueriesText(filters, sortOrder),
130126
database,
131127
action: 'execute-scan',
132128
},

src/store/reducers/executeTopQueries/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import type {TopQueriesFilters} from './types';
55
const endTimeColumn = 'EndTime';
66
const intervalEndColumn = 'IntervalEnd';
77

8-
const getMaxIntervalSubquery = (database: string) => `(
8+
const getMaxIntervalSubquery = () => `(
99
SELECT
1010
MAX(${intervalEndColumn})
11-
FROM \`${database}/.sys/top_queries_by_cpu_time_one_hour\`
11+
FROM \`.sys/top_queries_by_cpu_time_one_hour\`
1212
)`;
1313

14-
export function getFiltersConditions(database: string, filters?: TopQueriesFilters) {
14+
export function getFiltersConditions(filters?: TopQueriesFilters) {
1515
const conditions: string[] = [];
1616
const to = dateTimeParse(Number(filters?.to) || filters?.to)?.valueOf();
1717
const from = dateTimeParse(Number(filters?.from) || filters?.from)?.valueOf();
@@ -33,7 +33,7 @@ export function getFiltersConditions(database: string, filters?: TopQueriesFilte
3333

3434
// If there is no filters, return queries, that were executed in the last hour
3535
if (!from && !to) {
36-
conditions.push(`${intervalEndColumn} IN ${getMaxIntervalSubquery(database)}`);
36+
conditions.push(`${intervalEndColumn} IN ${getMaxIntervalSubquery()}`);
3737
}
3838

3939
if (filters?.text) {

src/store/reducers/shardsWorkload/shardsWorkload.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ function createShardQueryHistorical(
4242
filters?: ShardsWorkloadFilters,
4343
sortOrder?: SortOrder[],
4444
) {
45-
const pathSelect = database
46-
? `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS Path`
47-
: 'Path';
45+
const pathSelect = `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS Path`;
4846

4947
let where = `Path='${path}' OR Path LIKE '${path}/%'`;
5048

@@ -65,16 +63,14 @@ SELECT
6563
PeakTime,
6664
InFlightTxCount,
6765
IntervalEnd
68-
FROM \`${database}/.sys/top_partitions_one_hour\`
66+
FROM \`.sys/top_partitions_one_hour\`
6967
WHERE ${where}
7068
${orderBy}
7169
LIMIT 20`;
7270
}
7371

7472
function createShardQueryImmediate(path: string, database: string, sortOrder?: SortOrder[]) {
75-
const pathSelect = database
76-
? `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS Path`
77-
: 'Path';
73+
const pathSelect = `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS Path`;
7874

7975
const orderBy = prepareOrderByFromTableSort(sortOrder);
8076

@@ -86,7 +82,7 @@ SELECT
8682
DataSize,
8783
NodeId,
8884
InFlightTxCount
89-
FROM \`${database}/.sys/partition_stats\`
85+
FROM \`.sys/partition_stats\`
9086
WHERE
9187
Path='${path}'
9288
OR Path LIKE '${path}/%'

src/store/reducers/tenantOverview/executeTopTables/executeTopTables.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import {QUERY_TECHNICAL_MARK, TENANT_OVERVIEW_TABLES_LIMIT} from '../../../../ut
22
import {isQueryErrorResponse, parseQueryAPIResponse} from '../../../../utils/query';
33
import {api} from '../../api';
44

5-
const getQueryText = (database: string) => {
5+
const getQueryText = () => {
66
return `${QUERY_TECHNICAL_MARK}
77
SELECT
88
Path, SUM(DataSize) as Size
9-
FROM \`${database}/.sys/partition_stats\`
9+
FROM \`.sys/partition_stats\`
1010
GROUP BY Path
1111
ORDER BY Size DESC
1212
LIMIT ${TENANT_OVERVIEW_TABLES_LIMIT}
@@ -20,7 +20,7 @@ export const topTablesApi = api.injectEndpoints({
2020
try {
2121
const response = await window.api.viewer.sendQuery(
2222
{
23-
query: getQueryText(database),
23+
query: getQueryText(),
2424
database,
2525
action: 'execute-scan',
2626
},

src/store/reducers/tenantOverview/topShards/tenantOverviewTopShards.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ import {isQueryErrorResponse, parseQueryAPIResponse} from '../../../../utils/que
33
import {api} from '../../api';
44

55
function createShardQuery(path: string, database: string) {
6-
const pathSelect = database
7-
? `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS Path`
8-
: 'Path';
9-
6+
const pathSelect = `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS Path`;
107
return `${QUERY_TECHNICAL_MARK}
118
SELECT
129
${pathSelect},
1310
TabletId,
1411
CPUCores,
15-
FROM \`${database}/.sys/partition_stats\`
12+
FROM \`.sys/partition_stats\`
1613
WHERE
1714
Path='${path}'
1815
OR Path LIKE '${path}/%'

0 commit comments

Comments
 (0)