Skip to content

Commit

Permalink
removed previous schema preservation for nodes, edges (#209)
Browse files Browse the repository at this point in the history
* removed previous schema preservation for nodes, edges
---------
Co-authored-by: Michael Chin <chnmch@amazon.com>
  • Loading branch information
cubeddu authored Nov 28, 2023
1 parent 040f4e5 commit 90aec5d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The next release will include the following feature enhancements and bug fixes:

**Bug fixes**

- Fixed node and edge counts not updating on connection re-synchronization (<<https://github.com/aws/graph-explorer/pull/209>)
- Fixed issue with Transition2 findDOMNode deprecation (<https://github.com/aws/graph-explorer/pull/211>
- Fixed loading spinner rotation when synchronizing schema (<https://github.com/aws/graph-explorer/pull/207>)
- Fixed highlight not persisting on selected graph element (<https://github.com/aws/graph-explorer/pull/187>)
Expand Down
23 changes: 7 additions & 16 deletions packages/graph-explorer/src/hooks/useUpdateSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,28 @@ const useUpdateSchema = () => {
const currentSchema =
typeof schema === "function" ? schema(prevSchema) : schema;

// Preserve vertices counts
const vertices = (
currentSchema?.vertices ||
prevSchema?.vertices ||
[]
).map(vertex => {
const prevVertex = prevSchema?.vertices.find(
v => v.type === vertex.type
);
// Vertices counts
const vertices = (currentSchema?.vertices || []).map(vertex => {
return {
...vertex,
total: vertex.total ?? prevVertex?.total,
total: vertex.total,
};
});

// Preserve edges counts
// Edges counts
const edges = (currentSchema?.edges || prevSchema?.edges || []).map(
edge => {
const prevEdge = prevSchema?.edges.find(e => e.type === edge.type);
return {
...edge,
total: edge.total ?? prevEdge?.total,
total: edge.total,
};
}
);

updatedSchema.set(id, {
totalVertices:
currentSchema?.totalVertices || prevSchema?.totalVertices || 0,
totalVertices: currentSchema?.totalVertices || 0,
vertices,
totalEdges: currentSchema?.totalEdges || prevSchema?.totalEdges || 0,
totalEdges: currentSchema?.totalEdges || 0,
edges,
prefixes: prevSchema?.prefixes || [],
lastUpdate: !currentSchema ? prevSchema?.lastUpdate : new Date(),
Expand Down

0 comments on commit 90aec5d

Please sign in to comment.