mirror of
https://github.com/ZhuLinsen/daily_stock_analysis
synced 2026-09-20 10:53:33 +08:00
fix: preserve market scope in data sources
This commit is contained in:
@@ -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 }) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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></sub></sub> (Chinese-only) | Existing-source routing, fallback chains, and recommended configuration profiles |
|
||||
| [Data Center](data-center-diagnostics.md) <sub><sub></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
|
||||
|
||||
Reference in New Issue
Block a user