Browse Source

用户分析增加相关属性

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.4.2^2
zouap 4 years ago
parent
commit
6b06f4ce32
1 changed files with 43 additions and 40 deletions
  1. +43
    -40
      routers/repo/user_data_analysis.go

+ 43
- 40
routers/repo/user_data_analysis.go View File

@@ -55,12 +55,11 @@ func getExcelHeader(ctx *context.Context) map[string]string {
excelHeader = append(excelHeader, ctx.Tr("user.static.countdate"))

excelHeaderMap := make(map[string]string, 0)
var i, tmp byte
tmp = 'A'
i = 0

i := 0
for _, value := range excelHeader {
excelColumn := string(tmp+i) + fmt.Sprint(1)
//log.Info("excelColumn=" + excelColumn)
excelColumn := getColumn(i) + fmt.Sprint(1)
log.Info("excelColumn=" + excelColumn)
excelHeaderMap[excelColumn] = value
i++
}
@@ -69,73 +68,77 @@ func getExcelHeader(ctx *context.Context) map[string]string {

func writeExcel(row int, xlsx *excelize.File, sheetName string, userRecord *models.UserBusinessAnalysisAll) {
rows := fmt.Sprint(row)
var tmp byte
tmp = 'A'
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.ID)
tmp := 0
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.ID)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.Name)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.Name)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, fmt.Sprintf("%.2f", userRecord.UserIndex))
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, fmt.Sprintf("%.2f", userRecord.UserIndex))
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, fmt.Sprintf("%.2f", userRecord.UserIndexPrimitive))
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, fmt.Sprintf("%.2f", userRecord.UserIndexPrimitive))
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CodeMergeCount)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CodeMergeCount)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CommitCount)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CommitCount)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.IssueCount)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.IssueCount)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CommentCount)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CommentCount)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.FocusRepoCount)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.FocusRepoCount)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.StarRepoCount)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.StarRepoCount)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.LoginCount)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.LoginCount)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.WatchedCount)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.WatchedCount)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CommitCodeSize)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CommitCodeSize)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.SolveIssueCount)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.SolveIssueCount)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.EncyclopediasCount)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.EncyclopediasCount)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CreateRepoCount)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CreateRepoCount)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, fmt.Sprintf("%.2f", userRecord.OpenIIndex))
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, fmt.Sprintf("%.2f", userRecord.OpenIIndex))
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CloudBrainTaskNum)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CloudBrainTaskNum)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, fmt.Sprintf("%.2f", float64(userRecord.CloudBrainRunTime)/3600))
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, fmt.Sprintf("%.2f", float64(userRecord.CloudBrainRunTime)/3600))
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CommitDatasetNum)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CommitDatasetNum)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CommitModelCount)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CommitModelCount)
tmp = tmp + 1

xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.FocusOtherUser)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CollectDataset)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.FocusOtherUser)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CollectedDataset)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CollectDataset)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.RecommendDataset)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CollectedDataset)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CollectImage)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.RecommendDataset)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CollectedImage)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.RecommendImage)
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CollectImage)
tmp = tmp + 1
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CollectedImage)

xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.RecommendImage)
tmp = tmp + 1
formatTime := userRecord.RegistDate.Format("2006-01-02 15:04:05")
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, formatTime[0:len(formatTime)-3])
xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, formatTime[0:len(formatTime)-3])
formatTime = userRecord.DataDate
tmp = tmp + 1
xlsx.SetCellValue(sheetName, string(tmp)+rows, formatTime)

xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, formatTime)
}
func getColumn(tmp int) string {
if tmp < 26 {
return fmt.Sprint('A' + tmp)
} else {
return "A" + fmt.Sprint('A'+(tmp-26))
}
}

func queryUserDataPage(ctx *context.Context, tableName string, queryObj interface{}) {


Loading…
Cancel
Save