Skip to content

Commit

Permalink
Added Cross-cutting concerns to GA blacklist (#430)
Browse files Browse the repository at this point in the history
* Added Cross-cutting concerns to GA blacklist

* GA page linting

* Remove double brackets

* Fix GA loading disappearing

* rename variable
  • Loading branch information
john681611 authored and northdpole committed Oct 28, 2023
1 parent 177a853 commit edf5040
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 55 deletions.
10 changes: 5 additions & 5 deletions application/database/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand All @@ -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,
)

Expand Down
104 changes: 54 additions & 50 deletions application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ export const GapAnalysis = () => {
);
const [gapAnalysis, setGapAnalysis] = useState<Record<string, GapAnalysisPathStart>>();
const [activeIndex, SetActiveIndex] = useState<string>();
const [loading, setLoading] = useState<boolean>(false);
const [loadingStandards, setLoadingStandards] = useState<boolean>(false);
const [loadingGA, setLoadingGA] = useState<boolean>(false);
const [error, setError] = useState<string | null | object>(null);
const { apiUrl } = useEnvironment();

Expand All @@ -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;
Expand Down Expand Up @@ -226,50 +227,53 @@ export const GapAnalysis = () => {
</Table.Row>
</Table.Header>
<Table.Body>
<LoadingAndErrorIndicator loading={loading} error={error} />
<LoadingAndErrorIndicator loading={loadingGA || loadingStandards} error={error} />
{gapAnalysis && (
<>
{Object.keys(gapAnalysis)
.sort((a, b) =>
getDocumentDisplayName(gapAnalysis[a].start, true).localeCompare(getDocumentDisplayName(gapAnalysis[b].start, true))
).map((key) => (
<Table.Row key={key}>
<Table.Cell textAlign="left" verticalAlign="top" selectable>
<a href={getInternalUrl(gapAnalysis[key].start)} target="_blank">
<p>
<b>{getDocumentDisplayName(gapAnalysis[key].start, true)}</b>
</p>
</a>
</Table.Cell>
<Table.Cell style={{ minWidth: '35vw' }}>
{Object.values<any>(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 && (
<Accordion>
<Accordion.Title
active={activeIndex === key}
index={key}
onClick={handleAccordionClick}
>
<Button>More Links (Total: {Object.keys(gapAnalysis[key].paths).length})</Button>
</Accordion.Title>
<Accordion.Content active={activeIndex === key}>
{Object.values<any>(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))}
</Accordion.Content>
</Accordion>
)}
{Object.keys(gapAnalysis[key].paths).length === 0 && <i>No links Found</i>}
</Table.Cell>
</Table.Row>
))}
.sort((a, b) =>
getDocumentDisplayName(gapAnalysis[a].start, true).localeCompare(
getDocumentDisplayName(gapAnalysis[b].start, true)
)
)
.map((key) => (
<Table.Row key={key}>
<Table.Cell textAlign="left" verticalAlign="top" selectable>
<a href={getInternalUrl(gapAnalysis[key].start)} target="_blank">
<p>
<b>{getDocumentDisplayName(gapAnalysis[key].start, true)}</b>
</p>
</a>
</Table.Cell>
<Table.Cell style={{ minWidth: '35vw' }}>
{Object.values<any>(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 && (
<Accordion>
<Accordion.Title
active={activeIndex === key}
index={key}
onClick={handleAccordionClick}
>
<Button>More Links (Total: {Object.keys(gapAnalysis[key].paths).length})</Button>
</Accordion.Title>
<Accordion.Content active={activeIndex === key}>
{Object.values<any>(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))}
</Accordion.Content>
</Accordion>
)}
{Object.keys(gapAnalysis[key].paths).length === 0 && <i>No links Found</i>}
</Table.Cell>
</Table.Row>
))}
</>
)}
</Table.Body>
Expand Down

0 comments on commit edf5040

Please sign in to comment.