Skip to content

Commit

Permalink
fix: issues (#369)
Browse files Browse the repository at this point in the history
mod: code review
  • Loading branch information
hetao92 authored Nov 29, 2022
1 parent 358fc3e commit 6080d50
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 36 deletions.
8 changes: 4 additions & 4 deletions app/config/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ const service = {
deleteSketch: (id: string, config?) => {
return _delete(`/api/sketches/${id}`)(undefined, config);
},
getSchemaSnapshot: (space, config?) => {
return get(`/api/schema/${encodeURIComponent(space)}/snapshot`)(undefined, config);
getSchemaSnapshot: (params, config?) => {
return get(`/api/schema/snapshot`)(params, config);
},
updateSchemaSnapshot: (params, config?) => {
const { space, ...restParams } = params;
return put(`/api/schema/${encodeURIComponent(space)}/snapshot`)(restParams, config);
const { ...restParams } = params;
return put(`/api/schema/snapshot`)(restParams, config);
},
deleteFavorite: (id, config?) => {
return _delete(`/api/favorites/${id}`)(undefined, config);
Expand Down
2 changes: 1 addition & 1 deletion app/pages/MainPage/Header/HelpMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const HelpMenu = () => {
</Link>
},
{
key: 'feedback',
key: 'feedbackEntrance',
popupClassName: styles.accountMenu,
popupOffset: [-35, 20],
label: <Icon className={styles.navIcon} type="icon-navbar-feedback" />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ const SchemaVisualization = () => {
try {
await getEdgeList();
await getTagList();
const { vids, edges } = await getRandomEdgeData();
const { vids, edges, err } = await getRandomEdgeData();
if(err) {
message.warning(err);
return;
}
if(vids.length === 0) {
message.warning(intl.get('sketch.noData'));
return;
Expand Down
53 changes: 31 additions & 22 deletions app/stores/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,33 +693,42 @@ export class SchemaStore {
const vids:Set<string> = new Set();
const edges = [];
const edgeQuery = this.edgeList.map(edge => `MATCH ()-[e:${handleKeyword(edge.name)}]->() RETURN e LIMIT 10;`);
const { code, data } = await service.batchExecNGQL({
const { code, data, message } = await service.batchExecNGQL({
gqls: edgeQuery
});
if(code === 0) {
data.forEach(item => {
if(item.code === 0) {
const edgeList = item.data?.tables || [];
edgeList.forEach(item => {
const { dstID, srcID, edgeName } = item._edgesParsedList[0];
vids.add(srcID);
vids.add(dstID);
edges.push({
src: srcID,
dst: dstID,
name: edgeName,
properties: this.edgeList.find(i => i.name === edgeName).fields.map(field => ({
name: field.Field,
type: field.Type,
}))
});
let err;
if(code !== 0) {
return {
err: message
};
}
for(let i = 0; i < data.length; i++) {
const item = data[i];
if(item.code !== 0) {
err = item.message;
break;
} else {
const edgeList = item.data?.tables || [];
edgeList.forEach(item => {
const { dstID, srcID, edgeName } = item._edgesParsedList[0];
vids.add(srcID);
vids.add(dstID);
edges.push({
src: srcID,
dst: dstID,
name: edgeName,
properties: this.edgeList.find(i => i.name === edgeName).fields.map(field => ({
name: field.Field,
type: field.Type,
}))
});
}
});
});
}
}
return {
vids: [...vids],
edges
edges,
err
};
};

Expand All @@ -744,7 +753,7 @@ export class SchemaStore {
};

getSchemaSnapshot = async (space) => {
const res = await service.getSchemaSnapshot(space, {
const res = await service.getSchemaSnapshot({ space }, {
trackEventConfig: {
category: 'schema',
action: 'get_schema_visualization',
Expand Down
4 changes: 2 additions & 2 deletions server/api/studio/internal/handler/routes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions server/api/studio/internal/types/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions server/api/studio/restapi/schema.api
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
type (
GetSchemaSnapshotRequest {
Space string `path:"space"`
Space string `form:"space"`
}

UpdateSchemaSnapshotRequest {
Space string `path:"space"`
Space string `json:"space"`
Snapshot string `json:"snapshot"`
}

Expand All @@ -21,9 +21,9 @@ type (
service studio-api {
@doc "Update Schema Snapshot"
@handler Update
put /api/schema/:space/snapshot (UpdateSchemaSnapshotRequest)
put /api/schema/snapshot (UpdateSchemaSnapshotRequest)

@doc "Get Schema Snapshot"
@handler GetSnapshot
get /api/schema/:space/snapshot (GetSchemaSnapshotRequest) returns (SchemaSnapshot)
get /api/schema/snapshot (GetSchemaSnapshotRequest) returns (SchemaSnapshot)
}

0 comments on commit 6080d50

Please sign in to comment.