refactor: improve dataset item formatting and ensure consistent handling of unknown formats

This commit is contained in:
2025-10-19 14:23:09 +03:00
parent 657a95b33c
commit 1e291be7b5
2 changed files with 7 additions and 5 deletions

View File

@@ -290,15 +290,17 @@ async function renderDatasetList() {
// Format individual dataset items
const formatDatasetItem = (dataset) => {
let metaText;
const formatLabel = dataset.format ? dataset.format.toUpperCase() : 'UNKNOWN';
if (dataset.source === 'url') {
// Show metadata if available, otherwise just URL and format
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 {
metaText = `URL • ${dataset.format.toUpperCase()}`;
metaText = `URL • ${formatLabel}`;
}
} 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

View File

@@ -30,11 +30,11 @@ function traverseSpec(spec, callback, defaultReturn = null) {
for (const key of NESTED_SPEC_KEYS) {
if (Array.isArray(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;
}
} 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;
}
}