Browse Source

Merge pull request '解决用户分析查询昨天没有数据的问题。' (#953) from zouap_static into V20211115

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/953
Reviewed-by: ychao_1983 <ychao_1983@sina.com>
pull/961/head
ychao_1983 3 years ago
parent
commit
85535aa3f3
1 changed files with 4 additions and 17 deletions
  1. +4
    -17
      routers/repo/user_data_analysis.go

+ 4
- 17
routers/repo/user_data_analysis.go View File

@@ -4,7 +4,6 @@ import (
"fmt"
"net/http"
"net/url"
"strings"
"time"

"code.gitea.io/gitea/models"
@@ -39,6 +38,7 @@ func QueryUserStaticDataPage(ctx *context.Context) {
endTime = time.Now()
} else {
startTime, _ = time.ParseInLocation("2006-01-02", startDate, time.Local)
startTime = time.Date(startTime.Year(), startTime.Month(), startTime.Day(), 12, 0, 0, 0, startTime.Location())
settingStartTime, _ := time.Parse("2006-01-02", setting.RadarMap.RecordBeginTime)
if startTime.Unix() < settingStartTime.Unix() {
startTime = settingStartTime
@@ -46,6 +46,8 @@ func QueryUserStaticDataPage(ctx *context.Context) {
}
endTime, _ = time.ParseInLocation("2006-01-02", endDate, time.Local)
endTime = endTime.AddDate(0, 0, 1)
endTime = time.Date(endTime.Year(), endTime.Month(), endTime.Day(), 23, 59, 59, 0, startTime.Location())

isAll = false
log.Info("startTime=" + fmt.Sprint(startTime.Unix()) + " endDate=" + fmt.Sprint(endTime.Unix()))
}
@@ -126,23 +128,8 @@ func QueryUserStaticDataPage(ctx *context.Context) {

//设置默认打开的表单
xlsx.SetActiveSheet(index)
var filename string

nowTime := time.Now()
nowZeroTime := time.Date(nowTime.Year(), nowTime.Month(), nowTime.Day(), 0, 0, 0, 0, nowTime.Location())
if endTime.Unix() >= nowZeroTime.Unix() {
endDate = nowZeroTime.AddDate(0, 0, -1).Format("2006-01-02")
}

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"
}
filename := sheetName + "_" + ctx.Tr("user.static.all") + ".xlsx"

ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(filename))
ctx.Resp.Header().Set("Content-Type", "application/octet-stream")


Loading…
Cancel
Save