fix: deduplicate evidence refs in trend summaries
Backend: assemble_trend_with_evidence now deduplicates document IDs via dict.fromkeys() (the rollup code already did this, but the base assembly didn't — same doc could appear multiple times from different intelligence extractions). Frontend: Trends.tsx deduplicates via Set before rendering as a safety net for existing data already stored with duplicates.
This commit is contained in:
@@ -103,10 +103,10 @@ function TrendCard({ trend, onClick }: { trend: TrendSummary; onClick: () => voi
|
|||||||
)}
|
)}
|
||||||
{expanded && (
|
{expanded && (
|
||||||
<div className="mt-2 space-y-1 text-xs">
|
<div className="mt-2 space-y-1 text-xs">
|
||||||
{trend.top_supporting_evidence?.map((e, i) => (
|
{[...new Set(trend.top_supporting_evidence ?? [])].map((e, i) => (
|
||||||
<EvidenceRef key={i} id={e} direction="supporting" />
|
<EvidenceRef key={i} id={e} direction="supporting" />
|
||||||
))}
|
))}
|
||||||
{trend.top_opposing_evidence?.map((e, i) => (
|
{[...new Set(trend.top_opposing_evidence ?? [])].map((e, i) => (
|
||||||
<EvidenceRef key={i} id={e} direction="opposing" />
|
<EvidenceRef key={i} id={e} direction="opposing" />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -687,8 +687,8 @@ def assemble_trend_with_evidence(
|
|||||||
config = EvidenceRankConfig(max_refs=max_evidence)
|
config = EvidenceRankConfig(max_refs=max_evidence)
|
||||||
supporting_ranked, opposing_ranked = rank_evidence_detailed(signals, config)
|
supporting_ranked, opposing_ranked = rank_evidence_detailed(signals, config)
|
||||||
|
|
||||||
supporting = [r.document_id for r in supporting_ranked]
|
supporting = list(dict.fromkeys(r.document_id for r in supporting_ranked))
|
||||||
opposing = [r.document_id for r in opposing_ranked]
|
opposing = list(dict.fromkeys(r.document_id for r in opposing_ranked))
|
||||||
|
|
||||||
catalysts, risks = extract_catalysts_and_risks(impacts, signals)
|
catalysts, risks = extract_catalysts_and_risks(impacts, signals)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user