Skip to content

Topic detail: visibility trend chart still uses the legacy raw-average score, contradicting the headline score #685

Closed

Description

@gkhngyk

Problem

On the topic detail page the headline Visibility Score and the Visibility Trend chart come from two different scoring systems:

The legacy function's own comments admit the problem — "this JS path is used by the older codepath" and "realistic daily averages for a low-visibility brand sit in the 0.3–1.5 band". Result: a topic can show a headline score of ~12 while its trend line crawls near 1 — the chart looks broken and understates the topic badly.

Fix

The new-formula daily series already exists and already supports topic scoping: the visibility_rate_trend RPC (migration 00039) takes p_topic_id and covers brand + competitors. Point the topic detail's trend (the getVisibilityTrend(brandId, { topicId }) call in getTopicDetail) at that path — the same way the Insights page already consumes it (tracking.ts#L2246-L2303).

Second legacy caller worth migrating in the same sweep (or a follow-up): the Reports trend section at web/src/lib/actions/reports.ts#L991 — reports pair that trend with new-formula KPIs, so they carry the same mismatch. If both are migrated, getVisibilityTrend has no callers left and can be removed. (The MCP/agent surface computes its own aggregates and is out of scope here.)

Acceptance criteria

  • The topic trend chart's latest-day value sits on the same scale as the headline Visibility Score (blend formula), not the raw all-answers average.
  • Competitor series on the chart uses the same formula as the brand series.
  • Reports trend either migrated alongside or tracked in a follow-up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions