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

fix: fix empty props in template import #415

Merged
merged 3 commits into from
Jan 3, 2023

Conversation

hetao92
Copy link
Contributor

@hetao92 hetao92 commented Dec 29, 2022

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

Description:

How do you solve it?

Special notes for your reviewer, ex. impact of this fix, design document, etc:

Comment on lines 34 to 43
? tables.reduce((acc, cur) => {
if (cur.type === 'vertex') {
acc.push(cur.vid);
} else {
vertexIds.forEach(id => {
acc.push(cur[id].toString());
});
}
return acc;
}, []).filter(vertexId => vertexId !== '')
Copy link
Contributor

Choose a reason for hiding this comment

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

tables.reduce((acc, cur) => {
  if (cur.type === 'vertex') {
    cur.vid && acc.push(cur.vid);
  } else {
    vertexIds.forEach(id => {
      acc.push(cur[id].toString());
    });
  }
  return acc;
}, [])

Comment on lines 17 to 27
const [data, setData] = useState<{
list: {
Type: string,
Name: string,
Count: number,
}[],
total: {
vertices: number,
edges: number,
} | null
} | null>(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

const [data, setData] = useState<{
  list: { Type: string; Name: string; Count: number }[];
  total?: { vertices: number; edges: number };
}>({ list: [], total: undefined });

Comment on lines 66 to 79
const _data = data.tables.reduce((prev, cur) => {
if (cur.Type === 'Space') {
if(!prev.total) {
prev.total = {
vertex: 0,
edge: 0,
};
}
prev.total[cur.Name] = cur.Count;
} else {
prev.list.push(cur);
}
return prev;
}, { list: [], total: null });
Copy link
Contributor

@huaxiabuluo huaxiabuluo Dec 29, 2022

Choose a reason for hiding this comment

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

const nextData = data.tables.reduce((prev, cur) => {
  if (cur.Type === 'Space') {
    prev.total ||= { vertex: 0, edge: 0 };
    prev.total[cur.Name] = cur.Count;
  } else {
    prev.list.push(cur);
  }
  return prev;
}, { list: [], total: undefined } as typeof data });

// empty props in yaml will converted to null, but its required in nebula-importer
parseContent.files.forEach(file => {
if(file.schema.edge) {
file.schema.edge.props = file.schema.edge?.props || [];
Copy link
Contributor

Choose a reason for hiding this comment

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

file.schema.edge.props ||= [];

}
if(file.schema.vertex) {
file.schema.vertex?.tags.forEach(tag => {
tag.props = tag.props || [];
Copy link
Contributor

Choose a reason for hiding this comment

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

tag.props ||= [];

Copy link
Contributor

@huaxiabuluo huaxiabuluo left a comment

Choose a reason for hiding this comment

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

LGTM

@huaxiabuluo huaxiabuluo merged commit 479411d into vesoft-inc:master Jan 3, 2023
@hetao92 hetao92 deleted the hetao-fix branch January 3, 2023 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

使用YAML文件导入时的报错排查
2 participants