Skip to content

Commit

Permalink
feat: add tag flag in profiling computation
Browse files Browse the repository at this point in the history
  • Loading branch information
longxiaofei committed Jun 26, 2024
1 parent bf58f50 commit ba79f59
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -19,7 +18,7 @@ export interface FieldProfilingProps {
function NominalProfiling({ computation, field, valueRenderer = (s) => `${s}` }: FieldProfilingProps & { valueRenderer?: (v: string | number) => string }) {
const [stat, setStat] = useState<Awaited<ReturnType<typeof profileNonmialField>>>();
useEffect(() => {
profileNonmialField(computation, field).then(setStat);
profileNonmialField(wrapComputationWithTag(computation, "profiling"), field).then(setStat);
}, [computation, field]);

if (!isNotEmpty(stat)) {
Expand Down Expand Up @@ -85,7 +84,7 @@ const formatter = format('~s');
function QuantitativeProfiling({ computation, field }: FieldProfilingProps) {
const [stat, setStat] = useState<Awaited<ReturnType<typeof profileQuantitativeField>>>();
useEffect(() => {
profileQuantitativeField(computation, field).then(setStat);
profileQuantitativeField(wrapComputationWithTag(computation, "profiling"), field).then(setStat);
}, [computation, field]);
if (!isNotEmpty(stat)) {
return <div className="h-24 flex items-center justify-center">Loading...</div>;
Expand Down
9 changes: 9 additions & 0 deletions packages/graphic-walker/src/computation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
};
}
1 change: 1 addition & 0 deletions packages/graphic-walker/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ export type IDataQueryWorkflowStep = IFilterWorkflowStep | ITransformWorkflowSte

export interface IDataQueryPayload {
workflow: IDataQueryWorkflowStep[];
tag?: string;
limit?: number;
offset?: number;
}
Expand Down

0 comments on commit ba79f59

Please sign in to comment.