From ba79f59f657b8856d367c9c79ffcad3eb792bb37 Mon Sep 17 00:00:00 2001 From: longxiaofei Date: Wed, 26 Jun 2024 09:57:47 +0800 Subject: [PATCH] feat: add tag flag in profiling computation --- .../src/components/dataTable/profiling.tsx | 9 ++++----- packages/graphic-walker/src/computation/index.ts | 9 +++++++++ packages/graphic-walker/src/interfaces.ts | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/graphic-walker/src/components/dataTable/profiling.tsx b/packages/graphic-walker/src/components/dataTable/profiling.tsx index 5b9578d2..a23e50fe 100644 --- a/packages/graphic-walker/src/components/dataTable/profiling.tsx +++ b/packages/graphic-walker/src/components/dataTable/profiling.tsx @@ -1,15 +1,14 @@ import { ComponentType, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'; import { IComputationFunction, ISemanticType } from '../../interfaces'; -import { profileNonmialField, profileQuantitativeField } from '../../computation'; +import { profileNonmialField, profileQuantitativeField, wrapComputationWithTag } from '../../computation'; import React from 'react'; import { formatDate, isNotEmpty } from '../../utils'; import Tooltip from '../tooltip'; -import { uiThemeContext, themeContext, vegaThemeContext } from '../../store/theme'; +import { themeContext, vegaThemeContext } from '../../store/theme'; import { parsedOffsetDate } from '../../lib/op/offset'; import embed, { VisualizationSpec } from 'vega-embed'; import { format } from 'd3-format'; import { getTheme } from '../../utils/useTheme'; -import { parseColorToHSL } from '@/utils/colors'; export interface FieldProfilingProps { field: string; @@ -19,7 +18,7 @@ export interface FieldProfilingProps { function NominalProfiling({ computation, field, valueRenderer = (s) => `${s}` }: FieldProfilingProps & { valueRenderer?: (v: string | number) => string }) { const [stat, setStat] = useState>>(); useEffect(() => { - profileNonmialField(computation, field).then(setStat); + profileNonmialField(wrapComputationWithTag(computation, "profiling"), field).then(setStat); }, [computation, field]); if (!isNotEmpty(stat)) { @@ -85,7 +84,7 @@ const formatter = format('~s'); function QuantitativeProfiling({ computation, field }: FieldProfilingProps) { const [stat, setStat] = useState>>(); useEffect(() => { - profileQuantitativeField(computation, field).then(setStat); + profileQuantitativeField(wrapComputationWithTag(computation, "profiling"), field).then(setStat); }, [computation, field]); if (!isNotEmpty(stat)) { return
Loading...
; diff --git a/packages/graphic-walker/src/computation/index.ts b/packages/graphic-walker/src/computation/index.ts index 73a18e13..4074508e 100644 --- a/packages/graphic-walker/src/computation/index.ts +++ b/packages/graphic-walker/src/computation/index.ts @@ -640,3 +640,12 @@ export async function profileQuantitativeField(service: IComputationFunction, fi binValues, }; } + +export function wrapComputationWithTag(service: IComputationFunction, tag: string) { + return (payload: IDataQueryPayload) => { + return service({ + ...payload, + tag, + }); + }; +} diff --git a/packages/graphic-walker/src/interfaces.ts b/packages/graphic-walker/src/interfaces.ts index 3a3d9535..b66e359a 100644 --- a/packages/graphic-walker/src/interfaces.ts +++ b/packages/graphic-walker/src/interfaces.ts @@ -631,6 +631,7 @@ export type IDataQueryWorkflowStep = IFilterWorkflowStep | ITransformWorkflowSte export interface IDataQueryPayload { workflow: IDataQueryWorkflowStep[]; + tag?: string; limit?: number; offset?: number; }