mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-24 10:56:53 +00:00
fix: fixed metric having clause and traces order sorting
This commit is contained in:
parent
a71a2af0a8
commit
170e209c05
@ -7,9 +7,11 @@ import SpaceAggregationOptions from 'container/QueryBuilder/components/SpaceAggr
|
||||
import { GroupByFilter, OperatorsSelect } from 'container/QueryBuilder/filters';
|
||||
import { useQueryOperations } from 'hooks/queryBuilder/useQueryBuilderOperations';
|
||||
import { Info } from 'lucide-react';
|
||||
import { memo, useCallback, useMemo } from 'react';
|
||||
import { memo, useCallback, useEffect, useMemo } from 'react';
|
||||
import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
import { useQueryBuilderV2Context } from '../../QueryBuilderV2Context';
|
||||
|
||||
const MetricsAggregateSection = memo(function MetricsAggregateSection({
|
||||
query,
|
||||
index,
|
||||
@ -21,6 +23,7 @@ const MetricsAggregateSection = memo(function MetricsAggregateSection({
|
||||
version: string;
|
||||
panelType: PANEL_TYPES | null;
|
||||
}): JSX.Element {
|
||||
const { setAggregationOptions } = useQueryBuilderV2Context();
|
||||
const {
|
||||
operators,
|
||||
spaceAggregationOptions,
|
||||
@ -33,6 +36,21 @@ const MetricsAggregateSection = memo(function MetricsAggregateSection({
|
||||
entityVersion: version,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
console.log('query', query);
|
||||
setAggregationOptions([
|
||||
{
|
||||
func: query.spaceAggregation || 'count',
|
||||
arg: query.aggregateAttribute.key || '',
|
||||
},
|
||||
]);
|
||||
}, [
|
||||
query.spaceAggregation,
|
||||
query.aggregateAttribute.key,
|
||||
setAggregationOptions,
|
||||
query,
|
||||
]);
|
||||
|
||||
const handleChangeGroupByKeys = useCallback(
|
||||
(value: IBuilderQuery['groupBy']) => {
|
||||
handleChangeQueryData('groupBy', value);
|
||||
|
||||
@ -21,6 +21,7 @@ import useDragColumns from 'hooks/useDragColumns';
|
||||
import { getDraggedColumns } from 'hooks/useDragColumns/utils';
|
||||
import useUrlQueryData from 'hooks/useUrlQueryData';
|
||||
import { RowData } from 'lib/query/createTableColumnsFromQuery';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import { ArrowUp10, Minus } from 'lucide-react';
|
||||
import { useTimezone } from 'providers/Timezone';
|
||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
||||
@ -46,7 +47,7 @@ function ListView({ isFilterApplied }: ListViewProps): JSX.Element {
|
||||
|
||||
const panelType = panelTypeFromQueryBuilder || PANEL_TYPES.LIST;
|
||||
|
||||
const [orderDirection, setOrderDirection] = useState<string>('asc');
|
||||
const [orderDirection, setOrderDirection] = useState<string>('desc');
|
||||
|
||||
const {
|
||||
selectedTime: globalSelectedTime,
|
||||
@ -74,6 +75,23 @@ function ListView({ isFilterApplied }: ListViewProps): JSX.Element {
|
||||
const paginationConfig =
|
||||
paginationQueryData ?? getDefaultPaginationConfig(PER_PAGE_OPTIONS);
|
||||
|
||||
const requestQuery = useMemo(() => {
|
||||
const query = stagedQuery
|
||||
? cloneDeep(stagedQuery)
|
||||
: cloneDeep(initialQueriesMap.traces);
|
||||
|
||||
if (query.builder.queryData[0]) {
|
||||
query.builder.queryData[0].orderBy = [
|
||||
{
|
||||
columnName: 'timestamp',
|
||||
order: orderDirection as 'asc' | 'desc',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return query;
|
||||
}, [stagedQuery, orderDirection]);
|
||||
|
||||
const queryKey = useMemo(
|
||||
() => [
|
||||
REACT_QUERY_KEY.GET_QUERY_RANGE,
|
||||
@ -84,6 +102,7 @@ function ListView({ isFilterApplied }: ListViewProps): JSX.Element {
|
||||
panelType,
|
||||
paginationConfig,
|
||||
options?.selectColumns,
|
||||
orderDirection,
|
||||
],
|
||||
[
|
||||
stagedQuery,
|
||||
@ -93,12 +112,13 @@ function ListView({ isFilterApplied }: ListViewProps): JSX.Element {
|
||||
options?.selectColumns,
|
||||
maxTime,
|
||||
minTime,
|
||||
orderDirection,
|
||||
],
|
||||
);
|
||||
|
||||
const { data, isFetching, isLoading, isError } = useGetQueryRange(
|
||||
{
|
||||
query: stagedQuery || initialQueriesMap.traces,
|
||||
query: requestQuery,
|
||||
graphType: panelType,
|
||||
selectedTime: 'GLOBAL_TIME' as const,
|
||||
globalSelectedInterval: globalSelectedTime as CustomTimeType,
|
||||
|
||||
@ -29,7 +29,7 @@ function MetricsExplorerPage(): JSX.Element {
|
||||
[updateAllQueriesOperators],
|
||||
);
|
||||
|
||||
useShareBuilderUrl(defaultQuery);
|
||||
useShareBuilderUrl({ defaultValue: defaultQuery });
|
||||
|
||||
return (
|
||||
<div className="metrics-explorer-page">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user