Skip to content
Snippets Groups Projects
Commit f0fcf80e authored by Yorgo EL MOUBAYED's avatar Yorgo EL MOUBAYED
Browse files

Add utils files

parent c0499bcc
No related branches found
No related tags found
No related merge requests found
File added
from abc import ABCMeta
from neomodel import db
class NodeUtils:
__metaclass__ = ABCMeta
def serialize_relationships(self, nodes):
serialized_nodes = []
for node in nodes:
# serialize node
serialized_node = node.serialize
# UNCOMMENT to get relationship type
# results, colums = self.cypher('''
# START start_node=node({self}), end_node=node({end_node})
# MATCH (start_node)-[rel]-(end_node)
# RETURN type(rel) as node_relationship
# ''',
# {'end_node': node.id}
# )
# serialized_node['node_relationship'] = results[0][0]
serialized_nodes.append(serialized_node)
return serialized_nodes
from api.models.user_model import User
from api.models.construct_model import Construct
MODEL_ENTITIES = {
'Construct': Construct,
'User': User
}
def fetch_nodes(fetch_info):
node_type = fetch_info['node_type']
search_word = fetch_info['name']
country = fetch_info['country']
limit = fetch_info['limit']
start = ((fetch_info['page'] - 1) * limit)
end = start + limit
jurisdiction = fetch_info['jurisdiction']
node_set = filter_nodes(MODEL_ENTITIES[node_type], search_word, country, jurisdiction)
fetched_nodes = node_set[start:end]
return [node.serialize for node in fetched_nodes]
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment