add POST and GET views to connect with neo4j :)#5
Open
Twomac wants to merge 4 commits intoeons44:masterfrom
Open
add POST and GET views to connect with neo4j :)#5Twomac wants to merge 4 commits intoeons44:masterfrom
Twomac wants to merge 4 commits intoeons44:masterfrom
Conversation
adamjenkins1
requested changes
Oct 27, 2020
Collaborator
adamjenkins1
left a comment
There was a problem hiding this comment.
Congrats on making your first pull request! After addressing the comments, it would be great if you could use type hints so that the code is a little easier to read and add django unit tests to make sure that the views you've added behave how we expect.
adamjenkins1
reviewed
Nov 9, 2020
Collaborator
adamjenkins1
left a comment
There was a problem hiding this comment.
Much better. Once you add unit tests and create the Neo4jDriverHelper singleton, we'll be ready to merge these changes.
Comment on lines
+52
to
+69
| #FUNCTIONS THAT ACTUALLY CONNECT WITH THE DATABASE TO PERFORM TRANSACTIONS | ||
| def spawn_emotion_node(driver_arg, emotion): | ||
| with driver_arg.session() as session: | ||
| emotion_label = session.write_transaction(create_node_transaction, 'Emotion', 'name', emotion) | ||
| print(emotion_label) | ||
|
|
||
|
|
||
| def spawn_user_node(driver_arg, username): | ||
| with driver_arg.session() as session: | ||
| user_name = session.write_transaction(create_node_transaction, 'User', 'name', username) | ||
| print(user_name) | ||
|
|
||
|
|
||
| def register_emotion(driver_arg, username, emotion): | ||
| epoch_timestamp = time() | ||
| with driver_arg.session() as session: | ||
| seconds = session.write_transaction(create_epoch_relationship_between_user_and_emotion, emotion, username, epoch_timestamp) | ||
| print(seconds) |
Collaborator
There was a problem hiding this comment.
Can we remove these print statements?
Comment on lines
+92
to
+102
|
|
||
|
|
||
| @csrf_exempt | ||
| def index(request, user_id, emotion): | ||
| if request.method == 'POST': | ||
| return HttpResponse('From the heavens above to the Earth below, I alone will become the honored one.') | ||
|
|
||
| if request.method == 'GET': | ||
| return HttpResponse('From the heavens above to the Earth below, I alone will become the honored one.') | ||
|
|
||
| return HttpResponseNotFound() |
Collaborator
There was a problem hiding this comment.
Since we've decided to transition this to just a REST API, we can remove this view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.