Skip to content

fix 分数过大导致出现问题#21

Merged
chenyme merged 1 commit intomasterfrom
yyg
Jul 2, 2025
Merged

fix 分数过大导致出现问题#21
chenyme merged 1 commit intomasterfrom
yyg

Conversation

@yyg-max
Copy link
Copy Markdown
Collaborator

@yyg-max yyg-max commented Jul 2, 2025

No description provided.

@OrenZhang OrenZhang requested a review from Copilot July 2, 2025 09:31
@OrenZhang OrenZhang self-requested a review July 2, 2025 09:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where user scores exceeding the int8 range caused errors by centralizing score updates and adding clamping logic.

  • Replace inline GORM update in updateUserScore with a call to User.SetScore
  • Change SetScore signature from int8 to int and clamp values to MinUserScore/MaxUserScore

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/apps/oauth/tasks.go Swapped raw DB update for user.SetScore call in updateUserScore
internal/apps/oauth/models.go Updated SetScore to take an int, enforce bounds, and persist to DB
Comments suppressed due to low confidence (3)

internal/apps/oauth/models.go:61

  • [nitpick] Add a doc comment above SetScore to describe its parameters, side effects, and clamping behavior for better clarity.
func (u *User) SetScore(tx *gorm.DB, newScore int) error {

internal/apps/oauth/models.go:69

  • Add unit tests for SetScore covering cases where newScore is below MinUserScore and above MaxUserScore to verify that values are correctly clamped and persisted.
	return tx.Model(u).Update("score", u.Score).Error

internal/apps/oauth/models.go:62

  • There may be a type mismatch between newScore (int) and MinUserScore/MaxUserScore; consider aligning their types or explicitly casting the constants to avoid potential compilation issues.
	if newScore < MinUserScore {

@chenyme chenyme merged commit eb38433 into master Jul 2, 2025
8 checks passed
@OrenZhang OrenZhang deleted the yyg branch July 2, 2025 11:28
tabloving pushed a commit to tabloving/cdk that referenced this pull request Jul 3, 2025
feat(trace): trace injection for gin mysql redis
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.

5 participants