Skip to content

Commit

Permalink
fix: Resolved review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
praveen5959 committed Jan 16, 2025
1 parent 0213826 commit 42b8445
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/@types/parseable/api/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type LogsQuery = {
access: string[] | null;
};

export type GraphQuery = {
export type GraphQueryOpts = {
stream: string;
startTime: string;
endTime: string;
Expand Down
4 changes: 2 additions & 2 deletions src/api/query.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Axios } from './axios';
import { GRAPH_DATA_URL, LOG_QUERY_URL } from './constants';
import { GraphQuery, Log, LogsQuery, LogsResponseWithHeaders } from '@/@types/parseable/api/query';
import { GraphQueryOpts, Log, LogsQuery, LogsResponseWithHeaders } from '@/@types/parseable/api/query';
import timeRangeUtils from '@/utils/timeRangeUtils';
import { CorrelationQueryBuilder, QueryBuilder } from '@/utils/queryBuilder';

Expand Down Expand Up @@ -92,6 +92,6 @@ export const getQueryResultWithHeaders = (logsQuery: LogsQuery, query = '') => {
return Axios().post<LogsResponseWithHeaders>(endPoint, makeCustomQueryRequestData(logsQuery, query), {});
};

export const getGraphData = (data: GraphQuery) => {
export const getGraphData = (data: GraphQueryOpts) => {
return Axios().post<LogsResponseWithHeaders>(GRAPH_DATA_URL, data);
};
4 changes: 2 additions & 2 deletions src/hooks/useQueryResult.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getQueryResultWithHeaders, getQueryResult, getGraphData } from '@/api/query';
import { GraphQuery, LogsQuery } from '@/@types/parseable/api/query';
import { GraphQueryOpts, LogsQuery } from '@/@types/parseable/api/query';
import { notifications } from '@mantine/notifications';
import { isAxiosError, AxiosError } from 'axios';
import { IconCheck } from '@tabler/icons-react';
Expand Down Expand Up @@ -53,7 +53,7 @@ export const useQueryResult = () => {
};

export const useGraphData = () => {
const fetchGraphDataHandler = async (data: GraphQuery) => {
const fetchGraphDataHandler = async (data: GraphQueryOpts) => {
const response = await getGraphData(data);
if (response.status !== 200) {
throw new Error(response.statusText);
Expand Down
8 changes: 4 additions & 4 deletions src/pages/Correlation/components/MultiEventTimeLineGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ const MultiEventTimeLineGraph = () => {
const streamNames = Object.keys(fields);
const streamsToFetch = streamNames.filter((streamName) => !Object.keys(streamData).includes(streamName));
const totalMinutes = interval / (1000 * 60);
const numBins = totalMinutes < 10 ? totalMinutes : totalMinutes < 60 ? 10 : 60;
const queries = streamsToFetch.map((streamKey) => {
const numBins = Math.trunc(totalMinutes < 10 ? totalMinutes : totalMinutes < 60 ? 10 : 60);
const eventTimeLineGraphOpts = streamsToFetch.map((streamKey) => {
const logsQuery = {
stream: streamKey,
startTime: dayjs(startTime).toISOString(),
Expand All @@ -256,12 +256,12 @@ const MultiEventTimeLineGraph = () => {
};
return logsQuery;
});
Promise.all(queries.map((queryData: any) => fetchGraphDataMutation.mutateAsync(queryData)))
Promise.all(eventTimeLineGraphOpts.map((queryData: any) => fetchGraphDataMutation.mutateAsync(queryData)))
.then((results) => {
setMultipleStreamData((prevData: any) => {
const newData = { ...prevData };
results.forEach((result, index) => {
newData[queries[index].stream] = result;
newData[eventTimeLineGraphOpts[index].stream] = result;
});
return newData;
});
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Stream/components/EventTimeLineGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const EventTimeLineGraph = () => {
const adjustedEndTime = dayjs(endTime).startOf('minute');

const totalMinutes = interval / (1000 * 60);
const numBins = Math.ceil(totalMinutes < 10 ? totalMinutes : totalMinutes < 60 ? 10 : 60);
const numBins = Math.trunc(totalMinutes < 10 ? totalMinutes : totalMinutes < 60 ? 10 : 60);

const logsQuery = {
stream: localStream,
Expand Down

0 comments on commit 42b8445

Please sign in to comment.