Skip to content

Commit

Permalink
fix: add null check & visConfig forward (#137)
Browse files Browse the repository at this point in the history
* chore: add forward vis config

* fix: server computation add check
  • Loading branch information
islxyqwe authored Aug 8, 2023
1 parent ace0ef2 commit 63c3b65
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/graphic-walker/src/components/askViz/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import React, { useCallback, useState } from 'react';
import { useGlobalStore } from '../../store';
import { PaperAirplaneIcon } from '@heroicons/react/24/outline';
import Spinner from '../spinner';
import { IViewField, IVisSpec } from '../../interfaces';
import { IViewField } from '../../interfaces';
import { VisSpecWithHistory } from '../../models/visSpecHistory';
import { visSpecDecoder } from '../../utils/save';
import { visSpecDecoder, forwardVisualConfigs } from '../../utils/save';

type VEGALite = any;

Expand Down Expand Up @@ -52,7 +52,7 @@ const AskViz: React.FC<{api?: string; headers?: Record<string, string>}> = (prop
setLoading(true);
vizQuery(props.api ?? api, allFields, query, props.headers ?? {})
.then((data) => {
vizStore.visList.push(new VisSpecWithHistory(visSpecDecoder([data])[0]));
vizStore.visList.push(new VisSpecWithHistory(visSpecDecoder(forwardVisualConfigs([data]))[0]));
vizStore.selectVisualization(vizStore.visList.length - 1);
// const liteGW = parseGW(spec);
// vizStore.renderSpec(liteGW);
Expand Down
11 changes: 8 additions & 3 deletions packages/graphic-walker/src/computation/serverComputation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const datasetStatsServer = async (service: IComputationFunction): Promise
],
})) as [{ count: number }];
return {
rowCount: res[0].count,
rowCount: res[0]?.count ?? 0,
};
};

Expand Down Expand Up @@ -72,7 +72,7 @@ export const dataQueryServer = async (
}
const res = await service({
workflow,
limit
limit,
});
return res;
};
Expand Down Expand Up @@ -132,7 +132,12 @@ export const fieldStatServer = async (
},
],
};
const [rangeRes] = range
const [
rangeRes = {
[MIN_ID]: 0,
[MAX_ID]: 0,
},
] = range
? await service(rangeQueryPayload)
: [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/graphic-walker/src/dataSource/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const DemoDataAssets = true ? {
export const DemoDataAssets = process.env.NODE_ENV === 'production' ? {
CARS: "https://chspace.oss-cn-hongkong.aliyuncs.com/api/ds-cars-service.json",
STUDENTS: "https://chspace.oss-cn-hongkong.aliyuncs.com/api/ds-students-service.json",
BTC_GOLD: "https://chspace.oss-cn-hongkong.aliyuncs.com/api/ds_btc_gold_service.json",
Expand Down

1 comment on commit 63c3b65

@vercel
Copy link

@vercel vercel bot commented on 63c3b65 Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.