Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.21.12.1
zouap 3 years ago
parent
commit
e77dcc07cc
4 changed files with 35 additions and 15 deletions
  1. +10
    -7
      models/user_business_analysis.go
  2. +2
    -2
      options/locale/locale_en-US.ini
  3. +1
    -0
      options/locale/locale_zh-CN.ini
  4. +22
    -6
      routers/repo/user_data_analysis.go

+ 10
- 7
models/user_business_analysis.go View File

@@ -82,6 +82,7 @@ type UserBusinessAnalysisQueryOptions struct {
SortType string
StartTime int64
EndTime int64
IsAll bool
}

type UserBusinessAnalysisList []*UserBusinessAnalysis
@@ -162,7 +163,7 @@ func getLastCountDate() int64 {

func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusinessAnalysis, int64) {

log.Info("query startTime =" + fmt.Sprint(opts.StartTime) + " endTime=" + fmt.Sprint(opts.EndTime))
log.Info("query startTime =" + fmt.Sprint(opts.StartTime) + " endTime=" + fmt.Sprint(opts.EndTime) + " isAll=" + fmt.Sprint(opts.IsAll))
statictisSess := xStatistic.NewSession()
defer statictisSess.Close()

@@ -219,12 +220,14 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus
newAndCond = newAndCond.And(
newOrCond,
)
newAndCond = newAndCond.And(
builder.Gte{"count_date": opts.StartTime},
)
newAndCond = newAndCond.And(
builder.Lte{"count_date": opts.EndTime},
)
if !opts.IsAll {
newAndCond = newAndCond.And(
builder.Gte{"count_date": opts.StartTime},
)
newAndCond = newAndCond.And(
builder.Lte{"count_date": opts.EndTime},
)
}

userBusinessAnalysisList = make([]*UserBusinessAnalysis, 0)
if err := statictisSess.Table("user_business_analysis").Where(newAndCond).


+ 2
- 2
options/locale/locale_en-US.ini View File

@@ -420,7 +420,7 @@ static.createrepocount=Create Repo Count
static.openiindex=OpenI Index
static.registdate=Regist Date
static.countdate=Count Date
static.all=All

[settings]
profile = Profile
@@ -815,7 +815,7 @@ get_repo_stat_error=Can not get the statistics of the repository.
get_repo_info_error=Can not get the information of the repository.
generate_statistic_file_error=Fail to generate file.
repo_stat_inspect=ProjectAnalysis
all=all
all=All
modelarts.notebook=Debug Task
modelarts.train_job=Train Task
modelarts.train_job.new_debug= New Debug Task


+ 1
- 0
options/locale/locale_zh-CN.ini View File

@@ -423,6 +423,7 @@ static.createrepocount=创建项目数
static.openiindex=OpenI指数
static.registdate=用户注册时间
static.countdate=系统统计时间
static.all=所有
[settings]
profile=个人信息
account=账号


+ 22
- 6
routers/repo/user_data_analysis.go View File

@@ -40,12 +40,21 @@ func QueryUserStaticDataPage(ctx *context.Context) {
}
userName := ctx.Query("userName")
IsReturnFile := ctx.QueryBool("IsReturnFile")

log.Info("startDate=" + startDate + " endDate=" + endDate + " userName=" + userName + " page=" + fmt.Sprint(page))
startTime, _ := time.Parse("2006-01-02", startDate)
endTime, _ := time.Parse("2006-01-02", endDate)
endTime = endTime.AddDate(0, 0, 1)
log.Info("startTime=" + fmt.Sprint(startTime.Unix()) + " endDate=" + fmt.Sprint(endTime.Unix()))
var startTime time.Time
var endTime time.Time
var isAll bool
if startDate == "all" {
isAll = true
startTime = time.Now()
endTime = time.Now()
} else {
startTime, _ = time.Parse("2006-01-02", startDate)
endTime, _ = time.Parse("2006-01-02", endDate)
endTime = endTime.AddDate(0, 0, 1)
isAll = false
log.Info("startTime=" + fmt.Sprint(startTime.Unix()) + " endDate=" + fmt.Sprint(endTime.Unix()))
}

if IsReturnFile {
page = -1
@@ -60,6 +69,7 @@ func QueryUserStaticDataPage(ctx *context.Context) {
UserName: userName,
StartTime: startTime.Unix(),
EndTime: endTime.Unix(),
IsAll: isAll,
}
mapInterface := make(map[string]interface{})
re, count := models.QueryUserStaticDataPage(pageOpts)
@@ -120,7 +130,13 @@ func QueryUserStaticDataPage(ctx *context.Context) {

//设置默认打开的表单
xlsx.SetActiveSheet(index)
filename := sheetName + "_" + strings.ReplaceAll(startDate, "-", "") + "_" + strings.ReplaceAll(endDate, "-", "") + ".xlsx"
var filename string
if isAll {
filename = sheetName + "_" + ctx.Tr("user.static.all") + ".xlsx"
} else {
filename = sheetName + "_" + strings.ReplaceAll(startDate, "-", "") + "_" + strings.ReplaceAll(endDate, "-", "") + ".xlsx"
}

if len(userName) > 0 {
filename = sheetName + "_" + userName + "_" + strings.ReplaceAll(startDate, "-", "") + "_" + strings.ReplaceAll(endDate, "-", "") + ".xlsx"
}


Loading…
Cancel
Save