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

update db route #173

Open
wants to merge 1 commit into
base: master-2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cropontology/config/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

from ..views.template import TemplateLoadView, OntologyVersionView, CompareVersionView

from ..views.delete import DeleteOntologyView, DeleteTermView
from ..views.delete import DeleteOntologyView, DeleteTermView, UpdateDBView

from ..views.users import (
APIUserSearchSelect2,
Expand Down Expand Up @@ -441,6 +441,11 @@ def load_routes(config):
add_route("delete_term", "/delete-term/{term_id}", DeleteTermView, None)
)

# Here come the delete term view
routes.append(
add_route("update_db", "/update-db", UpdateDBView, None)
)

# Users API
routes.append(
add_route(
Expand Down
20 changes: 20 additions & 0 deletions cropontology/views/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,23 @@ def process_view(self):
response = Response(headerlist=headers, status=200)
response.text = "ok"
return response

class UpdateDBView(PublicView):
def process_view(self):
neo4j_bolt_url = self.request.registry.settings["neo4j.bolt.ulr"]
neo4j_user = self.request.registry.settings["neo4j.user"]
neo4j_password = self.request.registry.settings["neo4j.password"]
driver = GraphDatabase.driver(
neo4j_bolt_url, auth=(neo4j_user, neo4j_password)
)
db = driver.session()
query = (
"MATCH (n) SET n.entity = n.Entity REMOVE n.Entity RETURN n"
)
cursor = db.run(query)
query = (
"MATCH (n) SET n.date = n.data REMOVE n.data RETURN n"
)
cursor = db.run(query)
self.returnRawViewResult = True
return HTTPFound(location=self.request.route_url("home"))