fix: preserve market scope in data sources

This commit is contained in:
ZhuLinsen
2026-08-29 21:46:24 +08:00
parent e5f0d4106c
commit cc6009fcae
3 changed files with 30 additions and 11 deletions

View File

@@ -25,17 +25,18 @@ function formatDatasetMarkets(datasetMarkets: Record<string, string[]>): string
}
function formatDatasetSources(dataset: DataCapabilityOverview['datasets'][number]): string {
if (dataset.source) return dataset.source;
const markets = dataset.coverage?.markets;
if (!markets || typeof markets !== 'object' || Array.isArray(markets)) return '--';
const sources = Object.entries(markets)
.sort(([left], [right]) => left.localeCompare(right))
.flatMap(([market, value]) => {
if (!value || typeof value !== 'object' || Array.isArray(value)) return [];
const source = (value as Record<string, unknown>).source;
return typeof source === 'string' && source.trim() ? [`${market}: ${source.trim()}`] : [];
});
return sources.join(' / ') || '--';
if (markets && typeof markets === 'object' && !Array.isArray(markets)) {
const sources = Object.entries(markets)
.sort(([left], [right]) => left.localeCompare(right))
.flatMap(([market, value]) => {
if (!value || typeof value !== 'object' || Array.isArray(value)) return [];
const source = (value as Record<string, unknown>).source;
return typeof source === 'string' && source.trim() ? [`${market}: ${source.trim()}`] : [];
});
if (sources.length) return sources.join(' / ');
}
return dataset.source || '--';
}
function SummaryTile({ label, value, note }: { label: string; value: number; note: string }) {

View File

@@ -69,6 +69,23 @@ const overview = {
},
warnings: [],
},
{
dataset: 'daily.quality',
status: 'partial',
source: 'efinance',
stale: null,
lastSuccess: null,
lastError: null,
fallbackFrom: [],
coverage: {
markets: {
cn: { status: 'ok', source: 'efinance', fallback_from: [], warnings: [] },
hk: { status: 'unavailable', source: null, fallback_from: [], warnings: [] },
us: { status: 'unavailable', source: null, fallback_from: [], warnings: [] },
},
},
warnings: [],
},
],
priorities: [
{ scenario: 'cn.quote', providers: ['tencent', 'akshare'], source: 'runtime', warnings: [] },
@@ -90,6 +107,7 @@ describe('DataCenterPage', () => {
expect(screen.getByText('AkShare')).toBeInTheDocument();
expect(screen.getByText('screening.snapshot')).toBeInTheDocument();
expect(screen.getByText('cn: tencent / us: yfinance')).toBeInTheDocument();
expect(screen.getByText('cn: efinance')).toBeInTheDocument();
expect(screen.getAllByText('screening_health_unknown', { exact: false })).toHaveLength(2);
expect(screen.getByText('tencent → akshare')).toBeInTheDocument();
expect(screen.queryByText(/API[_ ]?KEY/i)).not.toBeInTheDocument();

View File

@@ -26,7 +26,7 @@ This is the entry point for project documentation. The README covers the project
| [Full Guide (EN)](full-guide_EN.md) | Environment setup, run modes, configuration, deployment paths, and common issues |
| [FAQ (EN)](FAQ_EN.md) | Common configuration, model, notification, deployment, and runtime issues |
| [Data-source stability diagrams](data-source-stability.md) <sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> (Chinese-only) | Existing-source routing, fallback chains, and recommended configuration profiles |
| [Data Center](data-center-diagnostics.md) <sub><sub>![P3 Badge](https://img.shields.io/badge/P3-yellow?style=flat)</sub></sub> (Chinese-only) | Read-only provider capabilities, exact dataset/market support, quality states, and runtime priorities |
| [Data Center](data-center-diagnostics.md) (Chinese-only) | Read-only provider capabilities, exact dataset/market support, quality states, and runtime priorities |
| [Changelog](CHANGELOG.md) | Release notes, capability changes, and migration notes |
## Configuration