Skip to content

fix: update task billing log content to include reason - #3093

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
feitianbubu:pr/92ad4854fcb501216dd9f2155c19f0556e4655bc
Mar 4, 2026
Merged

fix: update task billing log content to include reason#3093
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
feitianbubu:pr/92ad4854fcb501216dd9f2155c19f0556e4655bc

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Mar 3, 2026

Copy link
Copy Markdown
Member

将异步任务的计费过程显示到前端的其他详情中
image

Summary by CodeRabbit

  • Bug Fixes
    • Improved task billing log records to capture and display reasons more clearly and consistently.

@coderabbitai

coderabbitai Bot commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The RecalculateTaskQuota function in service/task_billing.go is modified to change how the reason is recorded. Instead of storing the reason in an "other" metadata map, the reason is now directly set to the Content field of the Task Billing Log.

Changes

Cohort / File(s) Summary
Task Billing Logging
service/task_billing.go
Modified reason storage in RecalculateTaskQuota: removed reason from "other" map and moved it to Task Billing Log's Content field for direct reason logging.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • xyfacai

Poem

🐰 A reason once hidden away,
Now shines in Content's bright display,
The map releases its guarded refrain,
As logging flows cleaner, more plain,
Hop hop—clarity wins the day! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: moving the reason field from the 'Other' metadata map to the Task Billing Log Content field for better frontend visibility.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@service/task_billing.go`:
- Around line 225-231: The review removed other["reason"] causing the frontend
“其他详情” to miss the reason; restore the reason into the Other map before calling
model.RecordTaskBillingLog so the payload used by the UI includes it.
Specifically, in service/task_billing.go ensure you set other["reason"] = reason
(alongside other["pre_consumed_quota"] and other["actual_quota"]) prior to
invoking model.RecordTaskBillingLog(model.RecordTaskBillingLogParams{...
Content: reason, ...}) so the Other field contains the reason for the record.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e71f5a4 and 5f3c5f1.

📒 Files selected for processing (1)
  • service/task_billing.go

Comment thread service/task_billing.go
Comment on lines +225 to +231
//other["reason"] = reason
other["pre_consumed_quota"] = preConsumedQuota
other["actual_quota"] = actualQuota
model.RecordTaskBillingLog(model.RecordTaskBillingLogParams{
UserId: task.UserId,
LogType: logType,
Content: "",
Content: reason,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Preserve reason in Other to satisfy the “其他详情” display goal.

At Line 225, other["reason"] is removed, and at Line 231 it is only written to Content. This can break the frontend “其他详情” payload that reads from Other, which is the stated PR objective.

Proposed fix
 	other := taskBillingOther(task)
 	other["task_id"] = task.TaskID
-	//other["reason"] = reason
+	other["reason"] = reason
 	other["pre_consumed_quota"] = preConsumedQuota
 	other["actual_quota"] = actualQuota
 	model.RecordTaskBillingLog(model.RecordTaskBillingLogParams{
 		UserId:    task.UserId,
 		LogType:   logType,
 		Content:   reason,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@service/task_billing.go` around lines 225 - 231, The review removed
other["reason"] causing the frontend “其他详情” to miss the reason; restore the
reason into the Other map before calling model.RecordTaskBillingLog so the
payload used by the UI includes it. Specifically, in service/task_billing.go
ensure you set other["reason"] = reason (alongside other["pre_consumed_quota"]
and other["actual_quota"]) prior to invoking
model.RecordTaskBillingLog(model.RecordTaskBillingLogParams{... Content: reason,
...}) so the Other field contains the reason for the record.

@Calcium-Ion
Calcium-Ion merged commit 34262dc into QuantumNous:main Mar 4, 2026
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
…1216dd9f2155c19f0556e4655bc

fix: update task billing log content to include reason
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