Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tag flag in profiling computation #396

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading