mirror of https://github.com/buster-so/buster.git
versioned asset details
This commit is contained in:
parent
72150c2ee1
commit
b699b9f2c9
|
@ -318,12 +318,24 @@ export async function getAssetDetailsById(
|
||||||
if (!metric) return null;
|
if (!metric) return null;
|
||||||
|
|
||||||
// Extract version number from version history
|
// Extract version number from version history
|
||||||
const versionNumber =
|
// versionHistory is a Record<string, {content, updated_at, version_number}>
|
||||||
typeof metric.versionHistory === 'object' &&
|
// Get the highest version number from the keys
|
||||||
metric.versionHistory &&
|
const versionNumber = (() => {
|
||||||
'version_number' in metric.versionHistory
|
if (!metric.versionHistory || typeof metric.versionHistory !== 'object') {
|
||||||
? (metric.versionHistory as { version_number: number }).version_number
|
return 1;
|
||||||
: 1;
|
}
|
||||||
|
|
||||||
|
const versionKeys = Object.keys(metric.versionHistory);
|
||||||
|
if (versionKeys.length === 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse version keys and find the highest
|
||||||
|
const versions = versionKeys
|
||||||
|
.map((key) => Number.parseInt(key, 10))
|
||||||
|
.filter((v) => !Number.isNaN(v));
|
||||||
|
return versions.length > 0 ? Math.max(...versions) : 1;
|
||||||
|
})();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: metric.id,
|
id: metric.id,
|
||||||
|
@ -350,12 +362,24 @@ export async function getAssetDetailsById(
|
||||||
if (!dashboard) return null;
|
if (!dashboard) return null;
|
||||||
|
|
||||||
// Extract version number from version history
|
// Extract version number from version history
|
||||||
const versionNumber =
|
// versionHistory is a Record<string, {content, updated_at, version_number}>
|
||||||
typeof dashboard.versionHistory === 'object' &&
|
// Get the highest version number from the keys
|
||||||
dashboard.versionHistory &&
|
const versionNumber = (() => {
|
||||||
'version_number' in dashboard.versionHistory
|
if (!dashboard.versionHistory || typeof dashboard.versionHistory !== 'object') {
|
||||||
? (dashboard.versionHistory as { version_number: number }).version_number
|
return 1;
|
||||||
: 1;
|
}
|
||||||
|
|
||||||
|
const versionKeys = Object.keys(dashboard.versionHistory);
|
||||||
|
if (versionKeys.length === 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse version keys and find the highest
|
||||||
|
const versions = versionKeys
|
||||||
|
.map((key) => Number.parseInt(key, 10))
|
||||||
|
.filter((v) => !Number.isNaN(v));
|
||||||
|
return versions.length > 0 ? Math.max(...versions) : 1;
|
||||||
|
})();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: dashboard.id,
|
id: dashboard.id,
|
||||||
|
|
Loading…
Reference in New Issue