diff --git a/application/database/db.py b/application/database/db.py index 22e7358be..32df2a605 100644 --- a/application/database/db.py +++ b/application/database/db.py @@ -1045,6 +1045,7 @@ def __create_dbnode(dbnode: Node): section=dbnode.section, section_id=dbnode.section_id, # dbnode.sectionID, subsection=dbnode.subsection or "", + hyperlink=dbnode.link or "", tooltype="", # dbnode.tooltype, ).save() elif dbnode.ntype == "Code": @@ -1056,7 +1057,7 @@ def __create_dbnode(dbnode: Node): links=[], # dbnode.links, tags=([dbnode.tags] if isinstance(dbnode.tags, str) else dbnode.tags), metadata="{}", # dbnode.metadata, - hyperlink="", # dbnode.hyperlink or "", + hyperlink=dbnode.link or "", version=dbnode.version or "", ).save() elif dbnode.ntype == "Tool": @@ -1074,7 +1075,7 @@ def __create_dbnode(dbnode: Node): links=[], # dbnode.links, tags=([dbnode.tags] if isinstance(dbnode.tags, str) else dbnode.tags), metadata="{}", # dbnode.metadata, - hyperlink="", # dbnode.hyperlink or "", + hyperlink=dbnode.link or "", version=dbnode.version or "", ).save() @@ -1093,6 +1094,7 @@ def __update_dbnode(dbnode: Node): existing.section = dbnode.section existing.section_id = dbnode.section_id # dbnode.sectionID existing.subsection = dbnode.subsection or "" + existing.hyperlink = dbnode.link or "" existing.tooltype = "" # dbnode.tooltype return existing.save() elif dbnode.ntype == "Code": @@ -1105,7 +1107,7 @@ def __update_dbnode(dbnode: Node): [dbnode.tags] if isinstance(dbnode.tags, str) else dbnode.tags ) existing.metadata = "{}" # dbnode.metadata, - existing.hyperlink = "" # dbnode.hyperlink or "", + existing.hyperlink = dbnode.link or "" existing.version = dbnode.version or "" return existing.save() elif dbnode.ntype == "Tool": @@ -1124,7 +1126,7 @@ def __update_dbnode(dbnode: Node): ttype = cre_defs.ToolTypes.Unknown existing.tooltype = ttype existing.metadata = "{}" # dbnode.metadata, - existing.hyperlink = "" # dbnode.hyperlink or "", + existing.hyperlink = dbnode.link or "" existing.version = dbnode.version or "" return existing.save() else: diff --git a/application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx b/application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx index 1e830112b..f7cf94aa7 100644 --- a/application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx +++ b/application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx @@ -195,7 +195,9 @@ export const GapAnalysis = () => { useEffect(() => { const fetchData = async () => { const result = await axios.get( - `${apiUrl}/map_analysis?standard=${BaseStandard}&standard=${CompareStandard}` + `${apiUrl}/map_analysis?standard=${encodeURIComponent( + BaseStandard || '' + )}&standard=${encodeURIComponent(CompareStandard || '')}` ); if (result.data.result) { setLoadingGA(false); @@ -218,7 +220,9 @@ export const GapAnalysis = () => { async (key) => { if (!gapAnalysis) return; const result = await axios.get( - `${apiUrl}/map_analysis_weak_links?standard=${BaseStandard}&standard=${CompareStandard}&key=${key}` + `${apiUrl}/map_analysis_weak_links?standard=${encodeURIComponent( + BaseStandard || '' + )}&standard=${encodeURIComponent(CompareStandard || '')}&key=${encodeURIComponent(key)}` ); if (result.data.result) { setGapAnalysis((prev) => { diff --git a/application/tests/db_test.py b/application/tests/db_test.py index 68362cfc2..b55baf02c 100644 --- a/application/tests/db_test.py +++ b/application/tests/db_test.py @@ -2127,6 +2127,41 @@ def test_neo_db_parse_node_tool(self): ) self.assertEqual(db.NEO_DB.parse_node(graph_node).todict(), expected.todict()) + def test_neo_db_create_dbnode_copies_hyperlink(self) -> None: + link = "https://example.com/standard#section" + for ntype, neo_class in ( + ("Standard", "NeoStandard"), + ("Code", "NeoCode"), + ("Tool", "NeoTool"), + ): + with self.subTest(ntype=ntype), patch.object( + getattr(db, neo_class), "save", lambda self: self + ): + dbnode = db.Node( + name="name", + ntype=ntype, + tags="", + section="section", + description="description", + link=link, + ) + neo_node = db.NEO_DB._NEO_DB__create_dbnode(dbnode) + self.assertEqual( + db.NEO_DB.parse_node_no_links(neo_node).hyperlink, link + ) + + def test_neo_db_update_dbnode_copies_hyperlink(self) -> None: + link = "https://example.com/standard#section" + for ntype in ("Standard", "Code", "Tool"): + existing = mock.MagicMock() + with self.subTest(ntype=ntype), patch( + "application.database.db._neo_node_first_or_none_by_document_id", + return_value=existing, + ): + dbnode = db.Node(name="name", ntype=ntype, tags="", link=link) + db.NEO_DB._NEO_DB__update_dbnode(dbnode) + self.assertEqual(existing.hyperlink, link) + def test_neo_db_parse_node_cre(self): name = "name" description = "description"