Skip to content

Commit

Permalink
Merge branch '8.16' into backport/8.16/pr-196122
Browse files Browse the repository at this point in the history
  • Loading branch information
achyutjhunjhunwala authored Oct 18, 2024
2 parents 6cd118d + 7d58ea5 commit 5a99fe2
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const convertToCumulativeSumColumns = (
// lens supports cumulative sum for count and sum as quick function
// and everything else as formula
if (subFunctionMetric.type !== 'count' && pipelineAgg.name !== 'sum') {
const metaValue = Number(meta?.replace(']', ''));
const metaValue = Number(meta?.replace(/\]/g, ''));
formula = getPipelineSeriesFormula(metric, metrics, subFunctionMetric, {
metaValue,
reducedTimeRange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const convertFormulaScriptForPercentileAggs = (
) => {
variables.forEach((variable) => {
const [_, meta] = variable?.field?.split('[') ?? [];
const metaValue = Number(meta?.replace(']', ''));
const metaValue = Number(meta?.replace(/\]/g, ''));
if (!metaValue) {
return;
}
Expand Down Expand Up @@ -163,7 +163,7 @@ export const convertOtherAggsToFormulaColumn = (
const metric = metrics[metrics.length - 1];
const [fieldId, meta] = metric?.field?.split('[') ?? [];
const subFunctionMetric = metrics.find(({ id }) => id === fieldId);
const metaValue = meta ? Number(meta?.replace(']', '')) : undefined;
const metaValue = meta ? Number(meta?.replace(/\]/g, '')) : undefined;

if (!subFunctionMetric) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const convertMovingAvgOrDerivativeToColumns = (
if (!pipelineAgg) {
return null;
}
const metaValue = Number(meta?.replace(']', ''));
const metaValue = Number(meta?.replace(/\]/g, ''));
const subMetricField = subFunctionMetric.field;
const [nestedFieldId, _] = subMetricField?.split('[') ?? [];
// support nested aggs with formula
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { addAdditionalArgs } from '.';
import { AdditionalArgs } from '../../types';

const escapeQuotes = (str: string) => {
return str?.replace(/'/g, "\\'");
return str?.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
};

const constructFilterRationFormula = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const getFormulaEquivalent = (
}

return getPipelineSeriesFormula(currentMetric, metrics, subFunctionMetric, {
metaValue: nestedMetaValue ? Number(nestedMetaValue?.replace(']', '')) : undefined,
metaValue: nestedMetaValue ? Number(nestedMetaValue?.replace(/\]/g, '')) : undefined,
reducedTimeRange,
timeShift,
});
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/graph/public/helpers/kql_encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import rison from '@kbn/rison';
import { Workspace } from '../types';

function escapeQuotes(str: string) {
return str.replace(/"/g, '\\"');
return str.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
}

export function asKQL(workspace: Workspace, joinBy: 'and' | 'or') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ describe('FormBasedDimensionEditor', () => {
// // press arrow up to go back to the beginning
await userEvent.type(comboBoxInput, '{ArrowUp}{ArrowUp}');
expect(getVisibleFieldSelectOptions()).toEqual(allOptions.slice(8));
});
}, 10000); // this test can be long running due to a big tree we're rendering and userEvent.type function that is slow

it('should hide fields that have no data', () => {
(useExistingFieldsReader as jest.Mock).mockImplementationOnce(() => {
Expand Down

0 comments on commit 5a99fe2

Please sign in to comment.