@rh-support/troubleshoot 2.4.5-beta.2 → 2.4.5-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchCVEData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFetchCVEData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFetchCVEData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFetchCVEData.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,0BAA0B,EAAkB,MAAM,iCAAiC,CAAC;AAI7F,wBAAgB,eAAe;;EAgH9B"}
|
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { search } from '@cee-eng/hydrajs';
|
|
11
|
+
import { useLRUCache } from '@rh-support/components';
|
|
11
12
|
import { getRecommendationTitle } from '@rh-support/utils';
|
|
12
13
|
import filter from 'lodash/filter';
|
|
13
14
|
import isArray from 'lodash/isArray';
|
|
@@ -20,7 +21,7 @@ import { useCaseDispatch, useCaseSelector } from '../context/CaseContext';
|
|
|
20
21
|
import { RecommendationStateContext } from '../context/RecommendationContext';
|
|
21
22
|
import { setCaseState } from '../reducers/CaseReducer';
|
|
22
23
|
import { findCVEsInString } from '../utils/caseUtils';
|
|
23
|
-
// custom hook for CVE workflow .
|
|
24
|
+
// custom hook for CVE workflow data.
|
|
24
25
|
export function useFetchCVEData() {
|
|
25
26
|
const caseDispatch = useCaseDispatch();
|
|
26
27
|
const { recommendationState } = useContext(RecommendationStateContext);
|
|
@@ -31,6 +32,7 @@ export function useFetchCVEData() {
|
|
|
31
32
|
summary: state.caseDetails.summary,
|
|
32
33
|
description: state.caseDetails.description,
|
|
33
34
|
}), isEqual);
|
|
35
|
+
const { getFromCache, setInCache } = useLRUCache(50);
|
|
34
36
|
const getFixedErrataByProduct = (releaseInfo, selectedProduct, selectedVersion) => {
|
|
35
37
|
var _a;
|
|
36
38
|
if (isEmpty(releaseInfo) || !isArray(releaseInfo) || !selectedProduct) {
|
|
@@ -63,7 +65,17 @@ export function useFetchCVEData() {
|
|
|
63
65
|
if (isEmpty(cveIds))
|
|
64
66
|
return [];
|
|
65
67
|
try {
|
|
66
|
-
const results = yield Promise.allSettled(map(cveIds, (id) =>
|
|
68
|
+
const results = yield Promise.allSettled(map(cveIds, (id) => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const cachedData = getFromCache(id);
|
|
70
|
+
if (cachedData) {
|
|
71
|
+
return cachedData;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const data = yield search.getCVEDetailsById(id);
|
|
75
|
+
setInCache(id, data);
|
|
76
|
+
return data;
|
|
77
|
+
}
|
|
78
|
+
})));
|
|
67
79
|
return map(filter(results, (result) => result.status === 'fulfilled'), (result) => result.value);
|
|
68
80
|
}
|
|
69
81
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/troubleshoot",
|
|
3
|
-
"version": "2.4.5-beta.
|
|
3
|
+
"version": "2.4.5-beta.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -134,5 +134,5 @@
|
|
|
134
134
|
"defaults and supports es6-module",
|
|
135
135
|
"maintained node versions"
|
|
136
136
|
],
|
|
137
|
-
"gitHead": "
|
|
137
|
+
"gitHead": "ea597c370ffa9a12fa15cd8e27add093384ca898"
|
|
138
138
|
}
|