Merge pull request #1038 from buster-so/dallin-bus-1872-dashboard-somehow-had-null-version-in-its-version-history

dashboard version fix
This commit is contained in:
dal 2025-09-22 13:40:38 -06:00 committed by GitHub
commit 73746af9fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 3 deletions

View File

@ -51,9 +51,12 @@ function getLatestVersionNumber(versionHistory: VersionHistory | null): number {
if (!versionHistory || Object.keys(versionHistory).length === 0) { if (!versionHistory || Object.keys(versionHistory).length === 0) {
return 0; return 0;
} }
// Get all version numbers from the record values // Get all version numbers from the record values, filtering out null/undefined/NaN
const versionNumbers = Object.values(versionHistory).map((v) => v.version_number); const versionNumbers = Object.values(versionHistory)
return Math.max(...versionNumbers); .map((v) => v.version_number)
.filter((n) => typeof n === 'number' && !Number.isNaN(n));
return versionNumbers.length > 0 ? Math.max(...versionNumbers) : 0;
} }
// Helper function to add dashboard version to history // Helper function to add dashboard version to history