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

未關閉 適合新手
#106 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
82/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
typescript
領域
api, data

研究方向

這個 bug 位於 src/tools/getSalesSummary.ts 的 toCsv 中,它僅從 Object.keys(rows[0]) 取得欄位集合。從那裡開始,然後閱讀有條件地加入 name 鍵的分組對應。在 src/tools/tests/sales.test.ts 中加入一個測試,其中只有排名較低的資料列有名稱,並確認它會為沒有名稱的資料列產生一個帶有空儲存格的 name 欄。執行 npm test。

由索引模型根據 Issue 內容生成。

描述

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

主要語言
TypeScript
星號
5
分支
2
PR 合併指標
30 天內沒有已合併 PR

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

TMHSDigital/steam-mcp 的其他 Issue

查看 TMHSDigital/steam-mcp 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。