Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ad692b0

Browse files
committed
bugfix
1 parent 6355c96 commit ad692b0

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/logic/rank.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"model"
1313
"time"
1414

15+
"github.com/garyburd/redigo/redis"
1516
"github.com/polaris1119/logger"
1617
"github.com/polaris1119/nosql"
1718
"github.com/polaris1119/times"
@@ -102,9 +103,20 @@ func (self RankLogic) FindMonthRank(ctx context.Context, objtype, num int) (resu
102103
func (RankLogic) findModelsByRank(resultSlice []interface{}, objtype, num int) (result interface{}) {
103104
objids := make([]int, 0, num)
104105
viewNums := make([]int, 0, num)
105-
for i, length := 0, len(resultSlice); i < length; i += 2 {
106-
objids = append(objids, resultSlice[i].(int))
107-
viewNums = append(viewNums, resultSlice[i+1].(int))
106+
107+
for len(resultSlice) > 0 {
108+
var (
109+
objid, viewNum int
110+
err error
111+
)
112+
resultSlice, err = redis.Scan(resultSlice, &objid, &viewNum)
113+
if err != nil {
114+
logger.Errorln("findModelsByRank redis Scan error:", err)
115+
return nil
116+
}
117+
118+
objids = append(objids, objid)
119+
viewNums = append(viewNums, viewNum)
108120
}
109121

110122
switch objtype {

src/vendor/manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@
293293
{
294294
"importpath": "github.com/polaris1119/nosql",
295295
"repository": "https://github.com/polaris1119/nosql",
296-
"revision": "cdbfc63534442f43330efa5800fb98fbc00ace5f",
296+
"revision": "5fdf0907446a240593948746a1640f7b677b2fba",
297297
"branch": "master"
298298
},
299299
{

0 commit comments

Comments
 (0)