Skip to content

Commit

Permalink
chore: use floor value as threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat616 committed Sep 10, 2023
1 parent c088af9 commit 1a051a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
15 changes: 10 additions & 5 deletions internal/logic/poll/ruling.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,27 @@ func (s *sPoll) GetRulingThreshold(isExpandedPoll bool, totalTickets int) int {
if totalTickets < consts.PollRulingNeedForCommonUserPollThreshold {
threshold = 100000 // 设置一个不可能达到的值
} else {
threshold = int(math.Round(float64(totalTickets) * consts.PollRulingNeedForCommonUserPollRate))
threshold = int(math.Floor(float64(totalTickets) * consts.PollRulingNeedForCommonUserPollRate))
}
} else {
if totalTickets < consts.PollRulingNormalThreshold {
threshold = consts.PollRulingInitThreshold
} else {
threshold = int(math.Round(float64(totalTickets) * consts.PollRulingNormalRate))
threshold = int(math.Floor(float64(totalTickets) * consts.PollRulingNormalRate))
}
}
return threshold
}

// DoRuling 处理投票
// nolint:gocyclo
func (s *sPoll) DoRuling(ctx context.Context, poll *entity.Poll, target consts.PollStatus) error {
if target != consts.PollStatusRejected && target != consts.PollStatusApproved && target != consts.PollStatusNeedModify {
//
//nolint:gocyclo
func (s *sPoll) DoRuling(
ctx context.Context,
poll *entity.Poll,
target consts.PollStatus,
) error {
if target != consts.PollStatusRejected && target != consts.PollStatusApproved && target != consts.PollStatusNeedModify { //nolint:lll
return gerror.New("无效的投票状态")
}
// 判断是否需要修改
Expand Down
3 changes: 2 additions & 1 deletion internal/service/poll.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1a051a7

Please sign in to comment.