fix: 优化列表切片长度处理逻辑
This commit is contained in:
parent
c7b35f8dcd
commit
777f86b152
|
|
@ -368,7 +368,13 @@ func (b *BbxtTools) GetProfitRankingSum(now time.Time) (report *ReportRes, err e
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if len(data.List) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
maxLen := 20
|
||||||
|
if len(data.List) < maxLen {
|
||||||
|
maxLen = len(data.List)
|
||||||
|
}
|
||||||
//排序
|
//排序
|
||||||
sort.Slice(data.List, func(i, j int) bool {
|
sort.Slice(data.List, func(i, j int) bool {
|
||||||
return data.List[i].HistoryOneDiff > data.List[j].HistoryOneDiff
|
return data.List[i].HistoryOneDiff > data.List[j].HistoryOneDiff
|
||||||
|
|
@ -376,7 +382,7 @@ func (b *BbxtTools) GetProfitRankingSum(now time.Time) (report *ReportRes, err e
|
||||||
//取前20和后20
|
//取前20和后20
|
||||||
var (
|
var (
|
||||||
total [][]string
|
total [][]string
|
||||||
top = data.List[:20]
|
top = data.List[:maxLen]
|
||||||
bottom = data.List[len(data.List)-20:]
|
bottom = data.List[len(data.List)-20:]
|
||||||
)
|
)
|
||||||
//合并前20和后20
|
//合并前20和后20
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue