Skip to content

Commit

Permalink
Correct query and value errors
Browse files Browse the repository at this point in the history
  • Loading branch information
john681611 committed Aug 11, 2023
1 parent d9007bf commit 7f68f86
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions application/database/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,36 +249,53 @@ def gap_analysis(self, name_1, name_2):
return
records, _, _ = self.driver.execute_query(
"MATCH"
"(KevinB:Node {name: $name1}), "
"(Al:Node {name: $name2}), "
"p = shortestPath((KevinB)-[*]-(Al)) "
"WHERE length(p) > 1 "
"(BaseStandard:Node {name: $name1}), "
"(CompareStandard:Node {name: $name2}), "
"p = shortestPath((BaseStandard)-[*]-(CompareStandard)) "
"WHERE length(p) > 1 AND ALL(n in NODES(p) WHERE n:CRE or n = BaseStandard or n = CompareStandard) "
"RETURN p ",
name1=name_1,
name2=name_2,
database_="neo4j"
)

def format_record(rec):
def format_segment(seg):
def format_segment(seg):
return {
"start": {
"name": seg.start_node["name"],
"sectionID": seg.start_node["section_id"],
"section": seg.start_node["section"],
"subsection": seg.start_node["subsection"],
"description": seg.start_node["description"],
"id": seg.start_node["id"]
},
"end": {
"name": seg.end_node["name"],
"sectionID": seg.end_node["section_id"],
"section": seg.end_node["section"],
"subsection": seg.end_node["subsection"],
"description": seg.end_node["description"],
"id": seg.end_node["id"]
},
"relationship": seg.type
}

def format_record(rec):
return {
"start": {
"name": rec.start_node["name"],
"sectionID": rec.start_node["section_id"],
"section": rec.start_node["section"],
"subsection": rec.start_node["subsection"],
"description": rec.start_node["description"],
"id": rec.start_node["id"]
},
"end": {
"name": rec.end_node["name"],
"sectionID": rec.end_node["section_id"],
"section": rec.end_node["section"],
"subsection": rec.end_node["subsection"],
"description": rec.end_node["description"],
"id": rec.end_node["id"]
},
"path": [format_segment(seg) for seg in rec.relationships]
Expand Down

0 comments on commit 7f68f86

Please sign in to comment.