[WIP] Add competitor sentiment view to dashboard and reports - #23
Merged
Conversation
7 tasks
Owner
|
Closes: #17 |
jaydestro
marked this pull request as ready for review
July 20, 2026 16:44
…ection - Extend _buildIndex in server.js to include competitorAggregates and competitorSourceFailures in each report's metadata entry, enabling the new API endpoint to serve them without re-parsing reports. - Add GET /api/competitor-sentiment endpoint that returns per-slug competitor mention volumes, sentiment distributions, source coverage, and failure states from the most recent scan with competitor data. Falls back to the newest scan when no scan has competitor mentions, so the endpoint always responds with a usable structure. - Add buildCompetitorSectionMd() helper and enhance readMarkdown() in server.js to synthesise a ## Competitor & Market Signals markdown section from the JSON sidecar when the markdown report omits it. The Reports → Competitors tab extraction regex already matches the generated heading, so both the full report view and the tab work consistently from the same structured data. - Add #dash-competitor-sentiment-card HTML card to index.html in the Community signals dashboard section, visually distinct from the primary sentiment card via a left accent border. - Add loadCompetitorSentiment() to dashboard-enhancer.js which fetches /api/competitor-sentiment and renders per-competitor rows (mention count, sentiment dot-bar, sources), stale-data and partial-coverage banners, and an Open report button that navigates to the Reports → Competitors tab. Handles no-config, no-data, error, and loading states. - Add competitor card styles to theme-scout.css: .dash-competitor-card, .comp-group, .comp-table, .comp-sent-dot, .comp-partial-warning, etc. - Add four new tests to report-index.test.js covering: - Reconciliation: competitor mentions do not affect primary sentiment totals - Partial-source failures propagated correctly - Multiple competitors aggregated independently - Round-trip through JSON sidecar (loadReport preserves competitor fields) Co-authored-by: jaydestro <2974195+jaydestro@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_buildIndexin server.js to includecompetitorAggregates+competitorSourceFailuresinreportsMeta/api/competitor-sentimentGET endpoint in server.jsloadCompetitorSentiment()to dashboard-enhancer.js — per-competitor rows, sentinel states, link to Reports → CompetitorsCompetitor & Market Signalsinline section from structured data (viabuildCompetitorSectionMd+ enhancedreadMarkdown)