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

feat: Add GET paths for parents and children + fix: Update Neo4J query #35

Merged
merged 4 commits into from
Sep 6, 2022

Conversation

aadarsh-ram
Copy link
Collaborator

@aadarsh-ram aadarsh-ram commented Jul 30, 2022

What

  • Adds GET paths /entry/{entry}/parents and /entry/{entry}/children
  • Used for finding parents and children of a node
  • Changed neo4j query to disallow partial updates

Related issue(s)

@aadarsh-ram aadarsh-ram requested a review from a team as a code owner July 30, 2022 08:27
@aadarsh-ram aadarsh-ram changed the title feat: Add GET paths for parents and children feat: Add GET paths for parents and children + fix: Change Neo4J query Aug 12, 2022
@aadarsh-ram aadarsh-ram changed the title feat: Add GET paths for parents and children + fix: Change Neo4J query feat: Add GET paths for parents and children + fix: Update Neo4J query Aug 12, 2022
Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

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

It's ok but I have one question:

  • Changed neo4j query to disallow partial updates
    Why do we want this ? Shan't it be a parameter or a specific url ?

Also if we have to push every key / values each time, we should refactor the code, because it can be done in only one query instead of so many.

backend/editor/entries.py Outdated Show resolved Hide resolved
@aadarsh-ram
Copy link
Collaborator Author

@alexgarel I have now figured out a new way to tackle this. I fetch the current node information and compare it with the node object received, to remove the deleted keys. Does this make sense?

@@ -74,9 +74,20 @@ def update_nodes(label, entry, incomingData):
if not re.match(r"^\w+$", key) or key == "id":
raise ValueError("Invalid key: %s", key)

# Get current node information and deleted keys
curr_node = list(get_nodes(label, entry).data()[0]['n'].keys())
deleted_keys = list(set(curr_node) ^ set(incomingData))
Copy link
Member

Choose a reason for hiding this comment

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

Don't you want to just remove keys where incoming data is null ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@alexgarel I added the check.

Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

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

I made a comment, but this can be ok, also like this. So fix it if you want.

@alexgarel alexgarel merged commit 44025da into main Sep 6, 2022
@alexgarel alexgarel deleted the relpaths branch September 6, 2022 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Update Neo4J query to disallow partial updates Add GET path for finding relationships of a node
2 participants