Skip to content

fix(discovery): read the session stats and duration the API actually sends - #49

Merged
jhosepmyr merged 2 commits into
developfrom
bugfix/discovery-history-stats-contract
Oct 7, 2026
Merged

jhosepmyr merged 2 commits into
developfrom
bugfix/discovery-history-stats-contract

Conversation

@jhosepmyr

Copy link
Copy Markdown
Contributor

Problem

In production, the session history (Captura › Historial) did not show the Historias / Aceptadas / Pendientes / Preguntas columns. Every live session showed "—" as its duration. The session separator in Captura never showed "N historias".

Root cause

  • Contract drift: DiscoverySessionResponse in the web expected storiesGeneratedCount, storiesAcceptedCount, pendingSuggestionsCount and questionsCount. The API sends storiesGenerated, storiesAccepted, suggestionsPending and questionsAsked, so showStats() was always false.
  • Duration: the cell only read audioDurationMs. Only uploaded recordings set that field; live sessions never do.

Fix

  • Model: uses the API field names and adds durationSeconds.
  • History: reads the new names. The duration cell prefers durationSeconds and falls back to audioDurationMs for older deployments.
  • Helpers: the logic moves to the pure helpers sessionDuration and hasSessionStats (history.helpers.ts).
  • Captura: the session separator reads storiesGenerated.

Companion API PR: Kntro-Soft/reqsai-api#99. It makes durationSeconds report the audio length of uploads and makes storiesAccepted count accepted suggestions. Without it, this PR still shows the stats columns and live durations.

Tests

  • ng test --watch=false: 40 files, 399 tests passed. That includes the new history.helpers.spec.ts (6 tests), also run alone.
  • ng lint: clean.
  • ng build: OK.

@jhosepmyr
jhosepmyr requested a review from Eric396 as a code owner October 7, 2026 19:13
@jhosepmyr
jhosepmyr merged commit f8ed1b9 into develop Oct 7, 2026
5 of 6 checks passed
@jhosepmyr jhosepmyr mentioned this pull request Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant