diff --git a/packages/rath-client/src/interfaces.ts b/packages/rath-client/src/interfaces.ts index 9518e464a..375d8c0c4 100644 --- a/packages/rath-client/src/interfaces.ts +++ b/packages/rath-client/src/interfaces.ts @@ -127,6 +127,10 @@ export interface PreferencePanelConfig { visMode: 'common' | 'dist'; nlg: boolean; excludeScaleZero: boolean; + viewSizeLimit: { + dimension: number; + measure: number; + } } export interface IDBFieldMeta { fid: string; diff --git a/packages/rath-client/src/loggers/dataImport.ts b/packages/rath-client/src/loggers/dataImport.ts index b3510c163..343bdca98 100644 --- a/packages/rath-client/src/loggers/dataImport.ts +++ b/packages/rath-client/src/loggers/dataImport.ts @@ -40,11 +40,7 @@ export async function dataBackup (file: File) { method: 'POST', credentials: 'include', body: data - }).then(res => res.json()) - .then(res => { - // eslint-disable-next-line no-console - console.log(res) - }).catch(err => { + }).then(res => res.json()).catch(err => { console.warn(err) }) } else { diff --git a/packages/rath-client/src/pages/dataSource/baseActions/mainActionButton.tsx b/packages/rath-client/src/pages/dataSource/baseActions/mainActionButton.tsx index 5b3efb738..c29de6ec1 100644 --- a/packages/rath-client/src/pages/dataSource/baseActions/mainActionButton.tsx +++ b/packages/rath-client/src/pages/dataSource/baseActions/mainActionButton.tsx @@ -5,6 +5,7 @@ import intl from 'react-intl-universal'; import { Menu, MenuButtonProps, MenuItem, MenuList, MenuPopover, MenuTrigger, SplitButton } from '@fluentui/react-components'; import { Poll24Regular } from '@fluentui/react-icons'; import va from '@vercel/analytics'; +import { toJS } from 'mobx'; import { EXPLORE_MODE, PIVOT_KEYS } from '../../../constants'; import { useGlobalStore } from '../../../store'; @@ -14,7 +15,7 @@ export const useActionModes = function () { const { exploreMode, taskMode } = commonStore; const { satisfyAnalysisCondition, fieldMetas } = dataSourceStore; const startMegaAutoAnalysis = useCallback(() => { - ltsPipeLineStore.startTask(taskMode).then(() => { + ltsPipeLineStore.startTask(taskMode, toJS(megaAutoStore.visualConfig.viewSizeLimit)).then(() => { megaAutoStore.emitViewChangeTransaction(0); }); commonStore.setAppKey(PIVOT_KEYS.megaAuto); diff --git a/packages/rath-client/src/pages/megaAutomation/index.tsx b/packages/rath-client/src/pages/megaAutomation/index.tsx index 42deb16e5..bdba1939f 100644 --- a/packages/rath-client/src/pages/megaAutomation/index.tsx +++ b/packages/rath-client/src/pages/megaAutomation/index.tsx @@ -2,7 +2,7 @@ import React, { useCallback, useRef } from 'react'; import { observer } from 'mobx-react-lite'; import styled from 'styled-components'; import intl from 'react-intl-universal'; -import { runInAction } from 'mobx'; +import { runInAction, toJS } from 'mobx'; import { DefaultButton, PrimaryButton } from '@fluentui/react'; import { useGlobalStore } from '../../store'; import { PIVOT_KEYS } from '../../constants'; @@ -82,7 +82,7 @@ const LTSPage: React.FC = () => { // }) // }, [megaAutoStore]) const startTask = useCallback(() => { - ltsPipeLineStore.startTask(taskMode).then(() => { + ltsPipeLineStore.startTask(taskMode, toJS(megaAutoStore.visualConfig.viewSizeLimit)).then(() => { megaAutoStore.emitViewChangeTransaction(0); }); commonStore.setAppKey(PIVOT_KEYS.megaAuto); diff --git a/packages/rath-client/src/pages/megaAutomation/preference.tsx b/packages/rath-client/src/pages/megaAutomation/preference.tsx index 27844c938..fd08e57c1 100644 --- a/packages/rath-client/src/pages/megaAutomation/preference.tsx +++ b/packages/rath-client/src/pages/megaAutomation/preference.tsx @@ -19,12 +19,13 @@ import { runInAction } from 'mobx'; import { useGlobalStore } from '../../store'; import { EXPLORE_VIEW_ORDER } from '../../store/megaAutomation'; import { IResizeMode } from '../../interfaces'; +import { Label } from '@fluentui/react-components'; const PreferencePanel: React.FC = () => { const { megaAutoStore } = useGlobalStore(); const { visualConfig, showPreferencePannel, nlgThreshold, vizMode } = megaAutoStore; - const { nlg } = visualConfig; + const { nlg, viewSizeLimit } = visualConfig; const orderOptions: IDropdownOption[] = Object.values(EXPLORE_VIEW_ORDER).map((or) => ({ text: intl.get(`megaAuto.orderBy.${or}`), @@ -52,8 +53,8 @@ const PreferencePanel: React.FC = () => { runInAction(() => { megaAutoStore.setShowPreferencePannel(false); megaAutoStore.refreshMainViewSpec(); - }) - }, [megaAutoStore]) + }); + }, [megaAutoStore]); const onRenderFooterContent = () => (
@@ -77,6 +78,20 @@ const PreferencePanel: React.FC = () => { closeButtonAriaLabel="Close" onRenderFooterContent={onRenderFooterContent} > + + + { + megaAutoStore.setVisualConig((cnf) => { + cnf.viewSizeLimit.measure = Number(v); + }); + }} + /> + this.fields.find(f => f.key === d)!.name)) const context = this; const DEFAULT_BIN_NUM = 16; - const { measures: globalMeasures, fieldDictonary } = context + const { measures: globalMeasures, fieldDictonary, params } = context let ansSpace: IInsightSpace[] = []; if (context.cube === null) return ansSpace; const globalCuboid = await context.cube.getCuboid([]); const globalDist = await globalCuboid.getAggregatedRows(globalMeasures, globalMeasures.map(() => 'dist')); const pureMeasureViewMeasures: string[][] = []; for (let measures of context.dataGraph.MClusters) { - if (measures.length > 4) { - pureMeasureViewMeasures.push(...getCombination(measures, 4, 4)) + if (measures.length > params.limit.measure) { + pureMeasureViewMeasures.push(...getCombination(measures, params.limit.measure, params.limit.measure)) } else { pureMeasureViewMeasures.push(measures) } @@ -372,6 +380,9 @@ export class RathEngine extends VIEngine { // FIXME: throtte ii % 10 === 0 && setStateInStorage('explore_progress', ii / viewSpaces.length) const { dimensions, measures } = space; + if (dimensions.length > params.limit.dimension || measures.length > params.limit.measure) { + continue; + } let dropSpace = false; const localCuboid = await context.cube.getCuboid(dimensions); await localCuboid.loadStateInCache(); diff --git a/packages/rath-client/src/workers/engine/service.ts b/packages/rath-client/src/workers/engine/service.ts index dbacc9008..117d34bbc 100644 --- a/packages/rath-client/src/workers/engine/service.ts +++ b/packages/rath-client/src/workers/engine/service.ts @@ -1,6 +1,6 @@ import { ICubeStorageManageMode, IFieldSummary, IInsightSpace, Cube, ViewSpace, StatFuncName } from "visual-insights"; -import { IFieldMeta, IRow, ISyncEngine } from "../../interfaces"; +import { IFieldMeta, IRow, ISyncEngine, PreferencePanelConfig } from "../../interfaces"; import { IRathStorage } from "../../utils/storage"; import { RathCHEngine } from "./clickhouse"; // import { isSetEqual } from "../../utils/index"; @@ -37,15 +37,16 @@ function destroyEngine () { EngineRef.current = null; } -type StartPipeLineProps = { +type StartPipeLineProps = ({ mode: 'webworker'; cubeStorageManageMode: ICubeStorageManageMode; dataSource: IRow[]; fieldMetas: IFieldMeta[]; } | { mode: 'clickhouse'; - fieldMetas: IFieldMeta[]; viewName: string; +}) & { + limit: PreferencePanelConfig['viewSizeLimit'] } async function startPipeLine (props: StartPipeLineProps) { @@ -56,10 +57,11 @@ async function startPipeLine (props: StartPipeLineProps) { let viewFields: IFieldSummary[] = []; times.push(performance.now()) if (EngineRef.mode === 'webworker' && props.mode === 'webworker') { - const { dataSource, fieldMetas } = props; + const { dataSource, fieldMetas, limit } = props; const fieldsProps = fieldMetas.map(f => ({ key: f.fid, semanticType: f.semanticType, analyticType: f.analyticType, dataType: '?' as '?' })); const engine = EngineRef.current; if (engine === null) throw new Error('Engine is not created.'); + engine.params.limit = limit engine.setData(dataSource) .setFields(fieldsProps) engine.univarSelection();