mirror of
https://github.com/olehomelchenko/astrolabe-nvc.git
synced 2025-12-21 21:22:23 +00:00
refactor: improve dataset item formatting and ensure consistent handling of unknown formats
This commit is contained in:
@@ -290,15 +290,17 @@ async function renderDatasetList() {
|
|||||||
// Format individual dataset items
|
// Format individual dataset items
|
||||||
const formatDatasetItem = (dataset) => {
|
const formatDatasetItem = (dataset) => {
|
||||||
let metaText;
|
let metaText;
|
||||||
|
const formatLabel = dataset.format ? dataset.format.toUpperCase() : 'UNKNOWN';
|
||||||
|
|
||||||
if (dataset.source === 'url') {
|
if (dataset.source === 'url') {
|
||||||
// Show metadata if available, otherwise just URL and format
|
// Show metadata if available, otherwise just URL and format
|
||||||
if (dataset.rowCount !== null && dataset.size !== null) {
|
if (dataset.rowCount !== null && dataset.size !== null) {
|
||||||
metaText = `URL • ${dataset.rowCount} rows • ${dataset.format.toUpperCase()} • ${formatBytes(dataset.size)}`;
|
metaText = `URL • ${dataset.rowCount} rows • ${formatLabel} • ${formatBytes(dataset.size)}`;
|
||||||
} else {
|
} else {
|
||||||
metaText = `URL • ${dataset.format.toUpperCase()}`;
|
metaText = `URL • ${formatLabel}`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
metaText = `${dataset.rowCount} rows • ${dataset.format.toUpperCase()} • ${formatBytes(dataset.size)}`;
|
metaText = `${dataset.rowCount} rows • ${formatLabel} • ${formatBytes(dataset.size)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count snippet usage and create badge
|
// Count snippet usage and create badge
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ function traverseSpec(spec, callback, defaultReturn = null) {
|
|||||||
for (const key of NESTED_SPEC_KEYS) {
|
for (const key of NESTED_SPEC_KEYS) {
|
||||||
if (Array.isArray(spec[key])) {
|
if (Array.isArray(spec[key])) {
|
||||||
for (const item of spec[key]) {
|
for (const item of spec[key]) {
|
||||||
const result = traverseSpec(item, callback, undefined);
|
const result = traverseSpec(item, callback, defaultReturn);
|
||||||
if (result !== undefined) return result;
|
if (result !== undefined) return result;
|
||||||
}
|
}
|
||||||
} else if (spec[key] && typeof spec[key] === 'object') {
|
} else if (spec[key] && typeof spec[key] === 'object') {
|
||||||
const result = traverseSpec(spec[key], callback, undefined);
|
const result = traverseSpec(spec[key], callback, defaultReturn);
|
||||||
if (result !== undefined) return result;
|
if (result !== undefined) return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user