vn6295337 Claude Opus 4.5 commited on
Commit
de975df
·
1 Parent(s): 904fcf4

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
- // Try multiple sources for profile data
515
- const multiSource = rawData.multi_source as Record<string, unknown> | undefined
516
- const valAll = multiSource?.valuation_all as Record<string, unknown> | undefined
517
- const fundsAll = multiSource?.fundamentals_all as Record<string, unknown> | undefined
518
 
519
- // Yahoo Finance profile (most complete)
520
- const yfValData = valAll?.yahoo_finance as Record<string, unknown> | undefined
521
- const yfProfile = yfValData?.data as Record<string, unknown> | undefined
522
- const yfProfileNested = yfProfile?.profile as Record<string, unknown> | undefined
523
 
524
- // SEC EDGAR company info
525
- const secData = fundsAll?.sec_edgar as Record<string, unknown> | undefined
526
- const secInfo = secData?.data as Record<string, unknown> | undefined
527
- const secCompanyInfo = secInfo?.company_info as Record<string, unknown> | undefined
528
 
529
- // Legacy fallback
530
- const legacyProfile = rawData.metrics?.valuation?.profile || rawData.company_info || {}
 
 
 
531
 
532
- // Merge sources (Yahoo Finance primary, SEC secondary, legacy fallback)
533
- const profile = { ...legacyProfile, ...secCompanyInfo, ...yfProfileNested, ...yfProfile }
534
 
535
- // Build HQ location from available fields
536
  let hqLocation = null
537
- const city = profile.city as string | undefined
538
- const state = profile.state as string | undefined
539
- const stateOrCountry = profile.stateOrCountry as string | undefined
540
- const country = profile.country as string | undefined
541
-
542
- if (city && (state || stateOrCountry)) {
543
- const stateVal = state || stateOrCountry
544
- hqLocation = country && country !== 'United States' && country !== 'US'
545
- ? `${city}, ${stateVal}, ${country}`
546
- : `${city}, ${stateVal}`
 
 
 
 
 
 
547
  }
548
 
549
  return {
550
- sector: profile.sector as string | null || null,
551
- industry: profile.industry as string | null || null,
552
  hqLocation,
553
- employees: profile.fullTimeEmployees as number | null || profile.employees as number | null || null,
554
- website: profile.website as string | null || null,
555
- sicDescription: profile.sicDescription as string | null || null,
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