Spaces:
Sleeping
Sleeping
Fix Company Profile paths to match Research Service structure
Browse files- Look at metrics.fundamentals.company for SEC EDGAR company info
- Extract sector from metrics.fundamentals.sector or multi_source
- Extract HQ from company.business_address (city, state_or_country)
- Add legacy fallback for rawData.company_info
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
frontend/src/components/MCPDataPanel.tsx
CHANGED
|
@@ -511,48 +511,51 @@ export function MCPDataPanel({ metrics, rawData, companyName, ticker, exchange,
|
|
| 511 |
const companyProfile = React.useMemo(() => {
|
| 512 |
if (!rawData) return null
|
| 513 |
|
| 514 |
-
//
|
| 515 |
-
const
|
| 516 |
-
const valAll = multiSource?.valuation_all as Record<string, unknown> | undefined
|
| 517 |
-
const fundsAll = multiSource?.fundamentals_all as Record<string, unknown> | undefined
|
| 518 |
|
| 519 |
-
//
|
| 520 |
-
const
|
| 521 |
-
const yfProfile = yfValData?.data as Record<string, unknown> | undefined
|
| 522 |
-
const yfProfileNested = yfProfile?.profile as Record<string, unknown> | undefined
|
| 523 |
|
| 524 |
-
//
|
| 525 |
-
const
|
| 526 |
-
const secInfo = secData?.data as Record<string, unknown> | undefined
|
| 527 |
-
const secCompanyInfo = secInfo?.company_info as Record<string, unknown> | undefined
|
| 528 |
|
| 529 |
-
//
|
| 530 |
-
const
|
|
|
|
|
|
|
|
|
|
| 531 |
|
| 532 |
-
//
|
| 533 |
-
const
|
| 534 |
|
| 535 |
-
// Build HQ location from
|
| 536 |
let hqLocation = null
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 547 |
}
|
| 548 |
|
| 549 |
return {
|
| 550 |
-
sector:
|
| 551 |
-
industry:
|
| 552 |
hqLocation,
|
| 553 |
-
employees:
|
| 554 |
-
website:
|
| 555 |
-
sicDescription:
|
| 556 |
}
|
| 557 |
}, [rawData])
|
| 558 |
|
|
|
|
| 511 |
const companyProfile = React.useMemo(() => {
|
| 512 |
if (!rawData) return null
|
| 513 |
|
| 514 |
+
// Path 1: metrics.fundamentals contains SEC EDGAR data
|
| 515 |
+
const fundamentals = rawData.metrics?.fundamentals as Record<string, unknown> | undefined
|
|
|
|
|
|
|
| 516 |
|
| 517 |
+
// Path 2: metrics.fundamentals.company (from orchestrator)
|
| 518 |
+
const company = fundamentals?.company as Record<string, unknown> | undefined
|
|
|
|
|
|
|
| 519 |
|
| 520 |
+
// Path 3: Root level sector from fundamentals
|
| 521 |
+
const rootSector = fundamentals?.sector as string | undefined
|
|
|
|
|
|
|
| 522 |
|
| 523 |
+
// Path 4: multi_source fallback
|
| 524 |
+
const multiSource = rawData.multi_source as Record<string, unknown> | undefined
|
| 525 |
+
const fundsAll = multiSource?.fundamentals_all as Record<string, unknown> | undefined
|
| 526 |
+
const secEdgarData = fundsAll?.sec_edgar as Record<string, unknown> | undefined
|
| 527 |
+
const secSector = secEdgarData?.sector as string | undefined
|
| 528 |
|
| 529 |
+
// Extract business_address from SEC EDGAR company info
|
| 530 |
+
const businessAddr = company?.business_address as Record<string, unknown> | undefined
|
| 531 |
|
| 532 |
+
// Build HQ location from business_address
|
| 533 |
let hqLocation = null
|
| 534 |
+
if (businessAddr) {
|
| 535 |
+
const city = businessAddr.city as string
|
| 536 |
+
const state = businessAddr.state_or_country as string || businessAddr.stateOrCountry as string || businessAddr.state as string
|
| 537 |
+
if (city && state) {
|
| 538 |
+
hqLocation = `${city}, ${state}`
|
| 539 |
+
}
|
| 540 |
+
}
|
| 541 |
+
|
| 542 |
+
// Legacy fallback for older data structures
|
| 543 |
+
const legacyProfile = rawData.company_info as Record<string, unknown> | undefined
|
| 544 |
+
if (!hqLocation && legacyProfile) {
|
| 545 |
+
const city = legacyProfile.city as string
|
| 546 |
+
const state = legacyProfile.state as string || legacyProfile.stateOrCountry as string
|
| 547 |
+
if (city && state) {
|
| 548 |
+
hqLocation = `${city}, ${state}`
|
| 549 |
+
}
|
| 550 |
}
|
| 551 |
|
| 552 |
return {
|
| 553 |
+
sector: rootSector || secSector || company?.sector as string || legacyProfile?.sector as string || null,
|
| 554 |
+
industry: company?.sic_description as string || legacyProfile?.industry as string || null,
|
| 555 |
hqLocation,
|
| 556 |
+
employees: legacyProfile?.fullTimeEmployees as number || legacyProfile?.employees as number || null,
|
| 557 |
+
website: legacyProfile?.website as string || null,
|
| 558 |
+
sicDescription: company?.sic_description as string || null,
|
| 559 |
}
|
| 560 |
}, [rawData])
|
| 561 |
|