Transpose financials tables and expose company KPI metrics
This commit is contained in:
@@ -44,12 +44,13 @@ function filingWithExtraction(): Filing {
|
||||
}
|
||||
|
||||
describe('filing response redaction', () => {
|
||||
it('removes internal extraction fields while preserving public analysis fields', () => {
|
||||
it('removes internal extraction fields while preserving public fields and company metrics', () => {
|
||||
const redacted = redactInternalFilingAnalysisFields(filingWithExtraction());
|
||||
|
||||
expect(redacted.analysis?.provider).toBe('zhipu');
|
||||
expect(redacted.analysis?.model).toBe('glm-4.7-flashx');
|
||||
expect(redacted.analysis?.text).toBe('Report text');
|
||||
expect(redacted.analysis?.companyMetrics).toEqual(['g']);
|
||||
expect(redacted.analysis?.extraction).toBeUndefined();
|
||||
expect(redacted.analysis?.extractionMeta).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -5,11 +5,15 @@ export function redactInternalFilingAnalysisFields(filing: Filing): Filing {
|
||||
return filing;
|
||||
}
|
||||
|
||||
const { extraction: _extraction, extractionMeta: _extractionMeta, ...analysis } = filing.analysis;
|
||||
const hasPublicFields = Object.keys(analysis).length > 0;
|
||||
const { extraction, extractionMeta: _extractionMeta, ...analysis } = filing.analysis;
|
||||
const companyMetrics = (extraction?.companySpecificData ?? []).filter((item) => item.trim().length > 0);
|
||||
const publicAnalysis = companyMetrics.length > 0
|
||||
? { ...analysis, companyMetrics }
|
||||
: analysis;
|
||||
const hasPublicFields = Object.keys(publicAnalysis).length > 0;
|
||||
|
||||
return {
|
||||
...filing,
|
||||
analysis: hasPublicFields ? analysis : null
|
||||
analysis: hasPublicFields ? publicAnalysis : null
|
||||
};
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ export type Filing = {
|
||||
model?: string;
|
||||
text?: string;
|
||||
legacyInsights?: string;
|
||||
companyMetrics?: string[];
|
||||
extraction?: FilingExtraction;
|
||||
extractionMeta?: FilingExtractionMeta;
|
||||
} | null;
|
||||
|
||||
Reference in New Issue
Block a user