Skip to content

Commit

Permalink
frontend is more forgivable to predicted semantic model that does not…
Browse files Browse the repository at this point in the history
… have enough data node
  • Loading branch information
Binh Vu committed Feb 13, 2024
1 parent 990fcda commit 6326d5a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion www/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sand",
"version": "2.2.1",
"version": "2.2.2",
"private": true,
"dependencies": {
"@ant-design/colors": "^6.0.0",
Expand Down
31 changes: 31 additions & 0 deletions www/src/models/AssistantService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,37 @@ export class AssistantService extends RStore<number, AssistantRecord> {
data: rawsm,
id: "",
}).graph;
// add back any data node that aren't in the graph
for (
let columnIndex = 0;
columnIndex < table.columns.length;
columnIndex++
) {
if (graph.nodeByColumnIndex(columnIndex) === undefined) {
let prefix = "dnode";
if (graph.hasNode(`${prefix}:${columnIndex}`)) {
for (let counter = 0; counter < 1000; counter++) {
prefix = `dnode-p${counter}`;
if (!graph.hasNode(`${prefix}:${columnIndex}`)) {
break;
}
}
}

if (graph.hasNode(`${prefix}:${columnIndex}`)) {
throw new Error(
`Cannot generate a unique id to create a node for column ${columnIndex} in the graph`
);
}

graph.addDataNode({
id: `${prefix}:${columnIndex}`,
label: table.columns[columnIndex],
columnIndex: columnIndex,
nodetype: "data_node",
});
}
}

// before set a new draft, check if an empty draft is there (as default) and remove it
const prevDrafts = this.smStore.getCreateDraftsByTable(table);
Expand Down
1 change: 1 addition & 0 deletions www/src/models/sm/SMGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ export class SMGraph {
throw new Error("Duplicated id");
}
this.nodeId2Index[node.id] = this.nodes.length;
this.column2nodeIndex[node.columnIndex] = this.nodes.length;
this.nodes.push(node);
this.version += 1;
this.stale = true;
Expand Down

0 comments on commit 6326d5a

Please sign in to comment.