Skip to content

Commit 19a88ed

Browse files
committed
Optimize dashboard loading time
1 parent 6a595c6 commit 19a88ed

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

index.html

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,32 +1087,41 @@ <h4>Overall Summary</h4>
10871087

10881088
updateLoadingDetails('Loading vulnerability data files...', loadedVersions, totalVersions);
10891089

1090-
for (const version of summary.scanned_versions) {
1090+
// Create all fetch promises to load files in parallel
1091+
const fetchPromises = summary.scanned_versions.map(async (version) => {
10911092
try {
1092-
// Convert file path: replace 'release/' with 'release_' for file names
10931093
const fileName = version.replace('release/', 'release_');
10941094
const response = await fetch(`${dataPath}${fileName}.json`);
10951095
const data = await response.json();
1096+
return { version, data, success: true };
1097+
} catch (error) {
1098+
console.warn(`Failed to load data for ${version}:`, error);
1099+
return { version, data: null, success: false };
1100+
}
1101+
});
1102+
1103+
// Execute all fetches in parallel
1104+
const results = await Promise.allSettled(fetchPromises);
1105+
1106+
// Process results
1107+
results.forEach((result) => {
1108+
if (result.status === 'fulfilled' && result.value.success) {
1109+
const { version, data } = result.value;
10961110

10971111
// Separate releases from release branches
10981112
if (version.startsWith('release_') || version.startsWith('release/') || version.startsWith('master-')) {
10991113
branches[version] = data;
11001114
} else {
11011115
releases[version] = data;
11021116
}
1103-
11041117
loadedVersions++;
1105-
updateLoadingDetails('Loading vulnerability data files...', loadedVersions, totalVersions);
1106-
1107-
// Update progress incrementally
1108-
const fileProgress = 10 + (loadedVersions / totalVersions) * 50; // 10% to 60%
1109-
updateProgressBar(fileProgress);
1110-
} catch (error) {
1111-
console.warn(`Failed to load data for ${version}:`, error);
1112-
loadedVersions++;
1113-
updateLoadingDetails('Loading vulnerability data files...', loadedVersions, totalVersions);
1118+
} else {
1119+
loadedVersions++; // Count failed loads too
11141120
}
1115-
}
1121+
});
1122+
1123+
updateLoadingDetails('Loading vulnerability data files...', loadedVersions, totalVersions);
1124+
updateProgressBar(60);
11161125

11171126
updateLoadingStep(1, 'completed');
11181127

0 commit comments

Comments
 (0)