getSalesSummary CSV drops the name column when the top group is unnamed

Offen Anfängerfreundlich
#106 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
82/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
api, data

Rechercherichtung

Der Bug ist in toCsv in src/tools/getSalesSummary.ts, das seine Spaltenmenge nur aus Object.keys(rows[0]) bezieht. Beginne dort und lies dann das Gruppen-Mapping, das den Schlüssel name bedingt hinzufügt. Füge einen Test in src/tools/tests/sales.test.ts hinzu, bei dem nur eine niedriger gerankte Zeile einen Namen hat, und bestätige, dass er eine Spalte name mit einer leeren Zelle für die unbenannte Zeile ergibt. Führe npm test aus.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug good first issue priority: low

Summary

steam_getSalesSummary with format: "csv" takes its columns from the first row only. When the top group has no name but later groups do, the name column is left out of the whole CSV.

Where

  • src/tools/getSalesSummary.ts (toCsv: const cols = Object.keys(rows[0]);)
  • src/tools/getSalesSummary.ts (group mapping: ...(name ? { name } : {}))

Details

function toCsv(rows: Array<Record<string, unknown>>): string {
  if (rows.length === 0) return "";
  const cols = Object.keys(rows[0]);
  ...
}

Each group only gets a name key when app_info, package_info, or country_info named it. Rows are sorted by net revenue, so whether the CSV has a name column depends on whether the top earner happened to be named. If row 0 is named and others are not, those get an empty cell, which is fine; the reverse loses every name.

Impact

Low. Steam normally returns names for the countries, apps, and packages on the page, so this needs an unnamed group at the top. When it happens, a spreadsheet export silently drops the names column.

Steps to reproduce

  1. Stub GetDetailedSales so the top-revenue row's country_code has no country_info entry and a smaller row's does.
  2. Call steam_getSalesSummary { start_date, format: "csv" }.
  3. The header has no name column.

Suggested fix

Build cols as the union of keys across all rows, in first-seen order, or always set name (empty string when unknown) so every row has the same keys.

Acceptance criteria

  • A test where only a lower row is named produces a name column with that name and an empty cell for the unnamed row.

Getting started

  • Relevant files: src/tools/getSalesSummary.ts, src/tools/__tests__/sales.test.ts
  • How to run tests: npm test

Filed by repo-audit/fix-issues at a23ec21. Severity: low. Effort: S. audit-key: bug|src/tools/getSalesSummary.ts|toCsv

Vorherrschende Sprache
TypeScript
Sterne
5
Forks
2
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus TMHSDigital/steam-mcp

Alle Issues in TMHSDigital/steam-mcp

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.