Skip to content

Commit

Permalink
logs/comments removed
Browse files Browse the repository at this point in the history
Signed-off-by: Ramneet Chopra <[email protected]>
  • Loading branch information
ramneet-persistent committed Oct 21, 2022
1 parent 79539bc commit a2c6858
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -416,19 +416,13 @@ export const Explorer = ({
};

const fetchDataUpdateChart = async (
startingTime?: string,
endingTime?: string,
startingTime?: string | undefined,
endingTime?: string | undefined,
updatedQuery?: any
) => {
console.log('IN FETCH DATA TEST@@@@ ===EXPLORER ======== updatedQuery', updatedQuery);
const curQuery = updatedQuery.query;
console.log('curQuery====', curQuery, 'appBasedRef.current', appBasedRef.current);
// const rawQueryStr = buildQuery(appBasedRef.current, curQuery![RAW_QUERY]);
// appBasedRef is empty in case of upadte chart/refresh query....have data in case of only app analytics app
const rawQueryStr = updatedQuery.query[RAW_QUERY];
console.log('rawQueryStr====', rawQueryStr);
const rawQueryStr = curQuery[RAW_QUERY];
const curIndex = getIndexPatternFromRawQuery(rawQueryStr);
console.log('curIndex===', curIndex);
if (isEmpty(rawQueryStr)) return;

if (isEmpty(curIndex)) {
Expand All @@ -437,9 +431,7 @@ export const Explorer = ({
}

let curTimestamp: string = curQuery![SELECTED_TIMESTAMP];
console.log('curTimestamp====', curTimestamp);
if (isEmpty(curTimestamp)) {
console.log('EMPTY curTimestamp');
const defaultTimestamp = await getDefaultTimestampByIndexPattern(curIndex);
if (isEmpty(defaultTimestamp.default_timestamp)) {
setToast(defaultTimestamp.message, 'danger');
Expand All @@ -451,8 +443,6 @@ export const Explorer = ({
}
}

// startingTime, endingTime code update ==pending
// !!!!! we dont have time upadted in case of update chart click
if (isEqual(typeof startingTime, 'undefined') && isEqual(typeof endingTime, 'undefined')) {
startingTime = curQuery![SELECTED_DATE_RANGE][0];
endingTime = curQuery![SELECTED_DATE_RANGE][1];
Expand Down Expand Up @@ -480,24 +470,17 @@ export const Explorer = ({

// search
if (finalQuery.match(PPL_STATS_REGEX)) {
console.log('FETCHDATA ===CHECK 1111111');
getVisualizations();
// commented as fields already fetched before update chart!!!!
// getAvailableFields(`search source=${curIndex}`);
} else {
// block never runs in case of update chart!!!!
console.log('FETCHDATA ===CHECK 22222222');
findAutoInterval(startTime, endTime);
if (isLiveTailOnRef.current) {
console.log('FETCHDATA ===CHECK 33333');
getLiveTail(undefined, (error) => {
const formattedError = formatError(error.name, error.message, error.body.message);
notifications.toasts.addError(formattedError, {
title: 'Error fetching events',
});
});
} else {
console.log('FETCHDATA ===CHECK 444444444');
getEvents(undefined, (error) => {
const formattedError = formatError(error.name, error.message, error.body.message);
notifications.toasts.addError(formattedError, {
Expand All @@ -507,20 +490,19 @@ export const Explorer = ({
}
getCountVisualizations(minInterval);
}
// not sure about live tail in case of upadte chart!!!!!
console.log('isLiveTailOnRef=====', isLiveTailOnRef);

// for comparing usage if for the same tab, user changed index from one to another
if (!isLiveTailOnRef.current) {
setPrevIndex(curTimestamp);
if (!queryRef.current!.isLoaded) {
// dispatch(
// changeQuery({
// tabId,
// query: {
// isLoaded: true,
// },
// })
// );
dispatch(
changeQuery({
tabId,
query: {
isLoaded: true,
},
})
);
}
}
};
Expand Down Expand Up @@ -967,7 +949,6 @@ export const Explorer = ({
};

const getUpdatedDataConfig = (statsToken: statsChunk) => {
console.log('getUpdatedDataConfig======= statsToken', statsToken);
if (statsToken === null) {
return {
[GROUPBY]: [],
Expand Down Expand Up @@ -1090,10 +1071,7 @@ export const Explorer = ({
[tempQuery, query, selectedContentTabId]
);

const handleQueryChange = async (newQuery: string) => {
console.log('handleQueryChange === IN EXPLORER ===newQuery==', newQuery);
setTempQuery(newQuery);
};
const handleQueryChange = async (newQuery: string) => setTempQuery(newQuery);

const handleSavingObject = async () => {
const currQuery = queryRef.current;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,22 +223,13 @@ export const DataConfigPanelItem = ({
})
);
} else {
console.log('data.query.rawQuery====', data.query.rawQuery);
const statsTokens = queryManager!.queryParser().parse(data.query.rawQuery).getStats();
const newQuery = queryManager!
.queryBuilder()
.build(data.query.rawQuery, composeAggregations(updatedConfigList, statsTokens));

const updatedQuery = {
tabId,
query: {
...data.query,
[RAW_QUERY]: newQuery,
},
};
batch(async () => {
// await handleQueryChange(newQuery); @@worked fine without this one also
// @@moving into/after fetch data
await handleQueryChange(newQuery);
await dispatch(
changeQuery({
tabId,
Expand All @@ -249,25 +240,24 @@ export const DataConfigPanelItem = ({
})
);
await fetchData();
// await fetchData(undefined, undefined, updatedQuery);
// await dispatch(
// changeVizConfig({
// tabId,
// vizId: visualizations.vis.name,
// data: {
// dataConfig: {
// ...userConfigs.dataConfig,
// [GROUPBY]: updatedConfigList[GROUPBY],
// [AGGREGATIONS]: updatedConfigList[AGGREGATIONS],
// [BREAKDOWNS]: updatedConfigList[BREAKDOWNS],
// [SPAN]:
// !isEmpty(updatedConfigList[GROUPBY]) && !isEmpty(updatedConfigList[AGGREGATIONS])
// ? updatedConfigList?.span
// : undefined,
// },
// },
// })
// );
await dispatch(
changeVizConfig({
tabId,
vizId: visualizations.vis.name,
data: {
dataConfig: {
...userConfigs.dataConfig,
[GROUPBY]: updatedConfigList[GROUPBY],
[AGGREGATIONS]: updatedConfigList[AGGREGATIONS],
[BREAKDOWNS]: updatedConfigList[BREAKDOWNS],
[SPAN]:
!isEmpty(updatedConfigList[GROUPBY]) && !isEmpty(updatedConfigList[AGGREGATIONS])
? updatedConfigList?.span
: undefined,
},
},
})
);
});
}
};
Expand All @@ -289,7 +279,6 @@ export const DataConfigPanelItem = ({
})
);
} else {
console.log('data.query.rawQuery====', data.query.rawQuery);
const statsTokens = queryManager!.queryParser().parse(data.query.rawQuery).getStats();
const newQuery = queryManager!
.queryBuilder()
Expand All @@ -302,26 +291,7 @@ export const DataConfigPanelItem = ({
[RAW_QUERY]: newQuery,
},
};
console.log('BEFORE FETCHDATATEST##### updatedQuery', updatedQuery);
fetchDataUpdateChart(undefined, undefined, updatedQuery);
// await dispatch(
// changeVizConfig({
// tabId,
// vizId: visualizations.vis.name,
// data: {
// dataConfig: {
// ...userConfigs.dataConfig,
// [GROUPBY]: updatedConfigList[GROUPBY],
// [AGGREGATIONS]: updatedConfigList[AGGREGATIONS],
// [BREAKDOWNS]: updatedConfigList[BREAKDOWNS],
// [SPAN]:
// !isEmpty(updatedConfigList[GROUPBY]) && !isEmpty(updatedConfigList[AGGREGATIONS])
// ? updatedConfigList?.span
// : undefined,
// },
// },
// })
// );
}
};

Expand Down

0 comments on commit a2c6858

Please sign in to comment.