Skip to content

fix: academe prediction of 0 (archived repo) renders as failure instead of 0% - #615

Open
zjncs wants to merge 1 commit into
oss-compass:mainfrom
zjncs:fix/academe-zero-prediction
Open

zjncs wants to merge 1 commit into
oss-compass:mainfrom
zjncs:fix/academe-zero-prediction

Conversation

@zjncs

@zjncs zjncs commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Problem

Experience.tsx:54 treats active === 0 as a fetch failure:

if (res.status === 200 && res?.data?.prediction?.active) {
  setPredict(toFixed(res.data.prediction.active * 100, 1));
} else {
  setErrorMsg(t('academe:failed_to_fetch_data'));
}

The live endpoint POST /api/beta/predict returns {"prediction":{"active":0.8265}} — a 0-1 probability. When the model returns exactly 0 (dead/archived repo), the truthy guard fails and a successful request renders the "failed to fetch data" error instead of a 0% progress bar.

Secondary falsy-zero: {predict && ...} hides the result section when predict is 0.

Fix

  • typeof res?.data?.prediction?.active === 'number' (0 is a valid number result)
  • {predict !== null && ...} (0 must display)

Verification

New Experience.test.tsx: mock getData resolving {status:200, data:{prediction:{active:0}}}, assert the error message does NOT appear. RED before (truthy guard fails on 0, error shows), GREEN after.

Risk

None — 0 is now correctly rendered as a 0% bar instead of an error message.

res.data.prediction.active 是 0-1 概率:active === 0(已归档/不活跃
仓库)是 API 的成功结果。此前的 truthy 守卫把 0 当成获取失败显示
"failed to fetch data" 错误,而非显示 0% 进度条。{predict && ...}
的 truthy 渲染守卫同理隐藏了 0% 结果区。

改为 typeof === 'number' 判定 + predict !== null 渲染守卫。
Copilot AI balanced review requested due to automatic review settings October 22, 2026 14:08
@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

@zjncs is attempting to deploy a commit to the codersett's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

This branch has not been deployed

No deployments
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.

2 participants