Skip to content

Commit f730f21

Browse files
committed
Enhance service mesh image validation and improve performance count fetch error handling
Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
1 parent 45c6731 commit f730f21

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

src/sections/Learn-Layer5/Chapters/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,16 @@ const Chapters = ({ chapterData, courseData, location, serviceMeshesList, TOCDat
6868
const availableServiceMeshesArray = getAvailableServiceMeshes();
6969

7070
const findServiceMeshImage = (images, serviceMesh) => images.find(image => image.name.toLowerCase() == serviceMesh);
71+
const hasMeshImageData = (meshImage) => {
72+
const imagePath = meshImage?.imagepath;
73+
return Boolean(imagePath?.childImageSharp?.gatsbyImageData || imagePath?.publicURL);
74+
};
7175
const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
7276

7377
const missingServiceMeshImages = availableServiceMeshesArray
7478
.filter(({ section }) => {
7579
const meshImage = findServiceMeshImage(serviceMeshImages, section);
76-
return !(meshImage && meshImage.imagepath?.childImageSharp?.gatsbyImageData);
80+
return !hasMeshImageData(meshImage);
7781
})
7882
.map(({ section }) => section);
7983

src/sections/Meshery/Features-Col/index.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,22 @@ const Features = () => {
6464

6565
useEffect(() => {
6666
fetch(performanceCountEndpoint)
67-
.then((response) => {
68-
if (!response.ok) {
69-
throw new Error(`HTTP error! status: ${response.status}`);
70-
}
71-
return response.json();
72-
})
73-
.then((resultcount) => {
74-
if (resultcount && typeof resultcount.total_runs === "number") {
75-
setPerformanceCount(resultcount.total_runs);
76-
}
77-
})
78-
.catch((error) => {
79-
console.log("Failed to fetch performance count:", error.message);
67+
.then((response) => {
68+
if (!response.ok) {
69+
setPerformanceCount(250000);
70+
throw new Error(`HTTP error! status: ${response.status}`);
71+
}
72+
return response.json();
73+
})
74+
.then((resultcount) => {
75+
if (resultcount && typeof resultcount.total_runs === "number") {
76+
setPerformanceCount(resultcount.total_runs);
77+
}
78+
})
79+
.catch((error) => {
80+
console.log("Failed to fetch performance count:", error.message);
8081
// Keep default value of 0 if fetch fails
81-
});
82+
});
8283
}, []);
8384

8485
const data = LifecycleFeature().features;

0 commit comments

Comments
 (0)