Skip to content

Commit

Permalink
fix: 修复BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
Lansongxx committed Apr 16, 2024
1 parent 5bc6b65 commit 1e21d29
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions biz/application/service/hot.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/zeromicro/go-zero/core/stores/redis"
"go.mongodb.org/mongo-driver/bson/primitive"
"math"
"math/rand"
"strconv"
"time"
)
Expand Down Expand Up @@ -108,17 +107,18 @@ func (s *HotService) IncrHotValue(ctx context.Context, req *gencontent.IncrHotVa
rankKey = consts.CommentRankKey
}

value, ok := s.Cache.Get(rankKey)
if !ok || nowHot > (value.(float64)) {
if !ok {
flag = true
} else {
d := math.Float64bits(nowHot/(value.(float64))) * 10
if d >= 100 || d <= uint64(rand.Intn(100)) {
flag = true
}
}
}
//value, ok := s.Cache.Get(rankKey)
//if !ok || nowHot > (value.(float64)) {
// if !ok {
// flag = true
// } else {
// d := math.Float64bits(nowHot/(value.(float64))) * 10
// if d >= 100 || d <= uint64(rand.Intn(100)) {
// flag = true
// }
// }
//}
flag = true
if flag {
val, err := s.Redis.EvalCtx(ctx, luaScript, []string{rankKey}, []any{nowHot, req.HotId})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
google.golang.org/grpc v1.61.0
)

//replace github.com/CloudStriver/service-idl-gen-go => ../service-idl-gen-go
replace github.com/CloudStriver/service-idl-gen-go => ../service-idl-gen-go
//replace github.com/CloudStriver/cloudmind-mq => ../cloudmind-mq

require (
Expand Down

0 comments on commit 1e21d29

Please sign in to comment.