AOSSIE-Org / AOSSIE-Org/OrgExplorer

[BUG]: computeHealthScore returns NaN when open_issues_count is missing

未關閉 適合新手
#211 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
JavaScript
星號
34
分支
92
平均合併
8 天 7 小時
30 天內合併 PR
12

描述

### Bug Description

computeHealthScore() in src/services/analytics.js computes issueHealth with an
unguarded repo.open_issues_count:

const total = (repo.open_issues_count || 0) + 10
const issueHealth = Math.max(0, 100 - (repo.open_issues_count / total) * 100)

The `total` line defends against a missing open_issues_count with `|| 0`, but the
issueHealth line uses the bare `repo.open_issues_count`. When the field is absent,
`undefined / total` is NaN, so issueHealth is NaN and the whole score collapses to
NaN — which then renders in the UI and corrupts any sorting/averaging built on it.

GitHub can omit open_issues_count, and the inconsistency (guarded on one line,
unguarded on the very next) makes this a clear oversight rather than intended behavior.

### Steps to Reproduce

1. Open src/services/analytics.js.
2. Call computeHealthScore with a repo that has a valid pushed_at but no open_issues_count:

```js
import { computeHealthScore } from './src/services/analytics.js'

computeHealthScore({ pushed_at: new Date().toISOString() }, 2) // -> NaN
```

3. Observe: the score is NaN, with no error thrown.

### Logs and Screenshots

Reproduced locally on main (Node v22.17.0):

```
computeHealthScore({ pushed_at: , /* no open_issues_count */ }, 2): NaN
computeHealthScore({}, 3): NaN
```

### Environment Details

- OS: Windows (MINGW64 / Git Bash)
- Browser: Chrome
- Node.js: 22.17.0
- Branch: main
- Affected function: computeHealthScore (src/services/analytics.js, issueHealth line)
- Note: the sibling `total` line already guards this field with `|| 0`; the fix is to
apply the same guard on the issueHealth line.

### Impact

Medium - Feature works but has issues

### Code of Conduct

- [x] I have joined the [Discord server](https://discord.gg/hjUhu33uAn) and will post updates there
- [x] I have searched existing issues to avoid duplicates

貢獻指南

開啟貢獻指南

研究方向

Open src/services/analytics.js and inspect computeHealthScore, especially the issueHealth calculation beside the guarded total calculation. Reproduce the missing open_issues_count case described in the issue, then verify that the returned score is numeric rather than NaN and that the existing valid-repository behavior remains intact.

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

評估

技術堆疊
javascript
領域
analytics
Issue 類型
缺陷
難度
1/5
預估耗時
1-3 小時
活躍度
活躍
描述清晰度
描述清楚
新手友好度
88/100

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

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