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

Abierto Apto para principiantes
#106 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
82/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript
Área
api, data

Línea de trabajo

El bug está en toCsv en src/tools/getSalesSummary.ts, que toma su conjunto de columnas solo de Object.keys(rows[0]). Empieza ahí, luego lee el mapeo de grupos que añade la clave name de forma condicional. Añade una prueba en src/tools/tests/sales.test.ts donde solo una fila de menor rango tenga un nombre, y confirma que produce una columna name con una celda vacía para la fila sin nombre. Ejecuta npm test.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
TypeScript
Estrellas
5
Forks
2
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TMHSDigital/steam-mcp

Todos los issues de TMHSDigital/steam-mcp

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.