Browse Source

Merge pull request '增加用户看板界面默认排序功能,解决 #786' (#825) from zouap_static into V20211115

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/825
Reviewed-by: lewis <747342561@qq.com>
tags/v1.21.12.1
lewis 4 years ago
parent
commit
d5fea6c43a
1 changed files with 15 additions and 8 deletions
  1. +15
    -8
      models/user_business_analysis.go

+ 15
- 8
models/user_business_analysis.go View File

@@ -3,6 +3,7 @@ package models
import (
"encoding/json"
"fmt"
"sort"
"time"

"code.gitea.io/gitea/modules/log"
@@ -82,6 +83,14 @@ type UserBusinessAnalysisQueryOptions struct {
EndTime int64
}

type UserBusinessAnalysisList []*UserBusinessAnalysis

func (ulist UserBusinessAnalysisList) Swap(i, j int) { ulist[i], ulist[j] = ulist[j], ulist[i] }
func (ulist UserBusinessAnalysisList) Len() int { return len(ulist) }
func (ulist UserBusinessAnalysisList) Less(i, j int) bool {
return ulist[i].CommitCount > ulist[j].CommitCount
}

func QueryUserStaticData(startTime int64, endTime int64) []*UserBusinessAnalysis {
log.Info("query startTime =" + fmt.Sprint(startTime) + " endTime=" + fmt.Sprint(endTime))
statictisSess := xStatistic.NewSession()
@@ -115,12 +124,11 @@ func QueryUserStaticData(startTime int64, endTime int64) []*UserBusinessAnalysis
}
}

userBusinessAnalysisReturnList := make([]*UserBusinessAnalysis, len(resultMap))
index := 0
userBusinessAnalysisReturnList := UserBusinessAnalysisList{}
for _, v := range resultMap {
userBusinessAnalysisReturnList[index] = v
index += 1
userBusinessAnalysisReturnList = append(userBusinessAnalysisReturnList, v)
}
sort.Sort(userBusinessAnalysisReturnList)
log.Info("return size=" + fmt.Sprint(len(userBusinessAnalysisReturnList)))
return userBusinessAnalysisReturnList
}
@@ -218,12 +226,11 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus
}
}

userBusinessAnalysisReturnList := make([]*UserBusinessAnalysis, len(resultMap))
index := 0
userBusinessAnalysisReturnList := UserBusinessAnalysisList{}
for _, v := range resultMap {
userBusinessAnalysisReturnList[index] = v
index += 1
userBusinessAnalysisReturnList = append(userBusinessAnalysisReturnList, v)
}
sort.Sort(userBusinessAnalysisReturnList)
log.Info("return size=" + fmt.Sprint(len(userBusinessAnalysisReturnList)))
return userBusinessAnalysisReturnList, count
}


Loading…
Cancel
Save