From edf5040523c2f4237403b64847821ed316cd8e7c Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:07:11 +0100 Subject: [PATCH] Added Cross-cutting concerns to GA blacklist (#430) * Added Cross-cutting concerns to GA blacklist * GA page linting * Remove double brackets * Fix GA loading disappearing * rename variable --- application/database/db.py | 10 +- .../src/pages/GapAnalysis/GapAnalysis.tsx | 104 +++++++++--------- 2 files changed, 59 insertions(+), 55 deletions(-) diff --git a/application/database/db.py b/application/database/db.py index 45ea9c70c..ec4254ae8 100644 --- a/application/database/db.py +++ b/application/database/db.py @@ -422,17 +422,17 @@ def link_CRE_to_Node(self, CRE_id, node_id, link_type): @classmethod def gap_analysis(self, name_1, name_2): base_standard = NeoStandard.nodes.filter(name=name_1) - + denylist = ["Cross-cutting concerns"] path_records_all, _ = db.cypher_query( """ OPTIONAL MATCH (BaseStandard:NeoStandard {name: $name1}) OPTIONAL MATCH (CompareStandard:NeoStandard {name: $name2}) OPTIONAL MATCH p = allShortestPaths((BaseStandard)-[*..20]-(CompareStandard)) WITH p - WHERE length(p) > 1 AND ALL(n in NODES(p) WHERE n:NeoCRE or n = BaseStandard or n = CompareStandard) + WHERE length(p) > 1 AND ALL(n in NODES(p) WHERE (n:NeoCRE or n = BaseStandard or n = CompareStandard) AND NOT n.name in $denylist) RETURN p """, - {"name1": name_1, "name2": name_2}, + {"name1": name_1, "name2": name_2, "denylist": denylist}, resolve_objects=True, ) @@ -442,10 +442,10 @@ def gap_analysis(self, name_1, name_2): OPTIONAL MATCH (CompareStandard:NeoStandard {name: $name2}) OPTIONAL MATCH p = allShortestPaths((BaseStandard)-[:(LINKED_TO|CONTAINS)*..20]-(CompareStandard)) WITH p - WHERE length(p) > 1 AND ALL(n in NODES(p) WHERE n:NeoCRE or n = BaseStandard or n = CompareStandard) + WHERE length(p) > 1 AND ALL(n in NODES(p) WHERE (n:NeoCRE or n = BaseStandard or n = CompareStandard) AND NOT n.name in $denylist) RETURN p """, - {"name1": name_1, "name2": name_2}, + {"name1": name_1, "name2": name_2, "denylist": denylist}, resolve_objects=True, ) diff --git a/application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx b/application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx index a251cf86a..e69d24726 100644 --- a/application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx +++ b/application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx @@ -127,7 +127,8 @@ export const GapAnalysis = () => { ); const [gapAnalysis, setGapAnalysis] = useState>(); const [activeIndex, SetActiveIndex] = useState(); - const [loading, setLoading] = useState(false); + const [loadingStandards, setLoadingStandards] = useState(false); + const [loadingGA, setLoadingGA] = useState(false); const [error, setError] = useState(null); const { apiUrl } = useEnvironment(); @@ -142,36 +143,36 @@ export const GapAnalysis = () => { useEffect(() => { const fetchData = async () => { const result = await axios.get(`${apiUrl}/standards`); - setLoading(false); + setLoadingStandards(false); setStandardOptions( standardOptionsDefault.concat(result.data.sort().map((x) => ({ key: x, text: x, value: x }))) ); }; - setLoading(true); + setLoadingStandards(true); fetchData().catch((e) => { - setLoading(false); + setLoadingStandards(false); setError(e.response.data.message ?? e.message); }); - }, [setStandardOptions, setLoading, setError]); + }, [setStandardOptions, setLoadingStandards, setError]); useEffect(() => { const fetchData = async () => { const result = await axios.get( `${apiUrl}/map_analysis?standard=${BaseStandard}&standard=${CompareStandard}` ); - setLoading(false); + setLoadingGA(false); setGapAnalysis(result.data); }; if (!BaseStandard || !CompareStandard || BaseStandard === CompareStandard) return; setGapAnalysis(undefined); - setLoading(true); + setLoadingGA(true); fetchData().catch((e) => { - setLoading(false); + setLoadingGA(false); setError(e.response.data.message ?? e.message); }); - }, [BaseStandard, CompareStandard, setGapAnalysis, setLoading, setError]); + }, [BaseStandard, CompareStandard, setGapAnalysis, setLoadingGA, setError]); const handleAccordionClick = (e, titleProps) => { const { index } = titleProps; @@ -226,50 +227,53 @@ export const GapAnalysis = () => { - + {gapAnalysis && ( <> {Object.keys(gapAnalysis) - .sort((a, b) => - getDocumentDisplayName(gapAnalysis[a].start, true).localeCompare(getDocumentDisplayName(gapAnalysis[b].start, true)) - ).map((key) => ( - - - -

- {getDocumentDisplayName(gapAnalysis[key].start, true)} -

-
-
- - {Object.values(gapAnalysis[key].paths) - .sort((a, b) => a.score - b.score) - .slice(0, GetStrongPathsCount(gapAnalysis[key].paths)) - .map((path) => GetResultLine(path, gapAnalysis, key))} - {Object.keys(gapAnalysis[key].paths).length > 3 && ( - - - - - - {Object.values(gapAnalysis[key].paths) - .sort((a, b) => a.score - b.score) - .slice( - GetStrongPathsCount(gapAnalysis[key].paths), - Object.keys(gapAnalysis[key].paths).length - ) - .map((path) => GetResultLine(path, gapAnalysis, key))} - - - )} - {Object.keys(gapAnalysis[key].paths).length === 0 && No links Found} - -
- ))} + .sort((a, b) => + getDocumentDisplayName(gapAnalysis[a].start, true).localeCompare( + getDocumentDisplayName(gapAnalysis[b].start, true) + ) + ) + .map((key) => ( + + + +

+ {getDocumentDisplayName(gapAnalysis[key].start, true)} +

+
+
+ + {Object.values(gapAnalysis[key].paths) + .sort((a, b) => a.score - b.score) + .slice(0, GetStrongPathsCount(gapAnalysis[key].paths)) + .map((path) => GetResultLine(path, gapAnalysis, key))} + {Object.keys(gapAnalysis[key].paths).length > 3 && ( + + + + + + {Object.values(gapAnalysis[key].paths) + .sort((a, b) => a.score - b.score) + .slice( + GetStrongPathsCount(gapAnalysis[key].paths), + Object.keys(gapAnalysis[key].paths).length + ) + .map((path) => GetResultLine(path, gapAnalysis, key))} + + + )} + {Object.keys(gapAnalysis[key].paths).length === 0 && No links Found} + +
+ ))} )}