Browse Source

Merge remote-tracking branch 'origin/V20211115' into zouap_static

pull/857/head
zouap 3 years ago
parent
commit
8b24631300
4 changed files with 16 additions and 46 deletions
  1. +0
    -12
      modules/cron/tasks_basic.go
  2. +6
    -26
      routers/api/v1/repo/repo_dashbord.go
  3. +5
    -4
      web_src/js/components/ProAnalysis.vue
  4. +5
    -4
      web_src/js/components/UserAnalysis.vue

+ 0
- 12
modules/cron/tasks_basic.go View File

@@ -11,7 +11,6 @@ import (
"code.gitea.io/gitea/models" "code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/migrations" "code.gitea.io/gitea/modules/migrations"
repository_service "code.gitea.io/gitea/modules/repository" repository_service "code.gitea.io/gitea/modules/repository"
api_repo "code.gitea.io/gitea/routers/api/v1/repo"
"code.gitea.io/gitea/routers/repo" "code.gitea.io/gitea/routers/repo"
mirror_service "code.gitea.io/gitea/services/mirror" mirror_service "code.gitea.io/gitea/services/mirror"
) )
@@ -186,17 +185,6 @@ func registerHandleSummaryStatistic() {
}) })
} }


func registerHandleClearRepoStatisticFile() {
RegisterTaskFatal("handle_repo_clear_statistic_file", &BaseConfig{
Enabled: true,
RunAtStart: false,
Schedule: "@daily",
}, func(ctx context.Context, _ *models.User, _ Config) error {
api_repo.ClearUnusedStatisticsFile()
return nil
})
}

func initBasicTasks() { func initBasicTasks() {
registerUpdateMirrorTask() registerUpdateMirrorTask()
registerRepoHealthCheck() registerRepoHealthCheck()


+ 6
- 26
routers/api/v1/repo/repo_dashbord.go View File

@@ -2,7 +2,6 @@ package repo


import ( import (
"fmt" "fmt"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
@@ -174,7 +173,7 @@ func ServeAllProjectsPeriodStatisticsFile(ctx *context.Context) {
return return
} }
var projectAnalysis = ctx.Tr("repo.repo_stat_inspect") var projectAnalysis = ctx.Tr("repo.repo_stat_inspect")
fileName, frontName := getFileName(ctx, beginTime, endTime, projectAnalysis)
fileName := getFileName(ctx, beginTime, endTime, projectAnalysis)


if err := os.MkdirAll(setting.RadarMap.Path, os.ModePerm); err != nil { if err := os.MkdirAll(setting.RadarMap.Path, os.ModePerm); err != nil {
ctx.Error(http.StatusBadRequest, fmt.Errorf("Failed to create dir %s: %v", setting.AvatarUploadPath, err).Error()) ctx.Error(http.StatusBadRequest, fmt.Errorf("Failed to create dir %s: %v", setting.AvatarUploadPath, err).Error())
@@ -207,17 +206,14 @@ func ServeAllProjectsPeriodStatisticsFile(ctx *context.Context) {
f.SetActiveSheet(index) f.SetActiveSheet(index)
f.DeleteSheet("Sheet1") f.DeleteSheet("Sheet1")


if err := f.SaveAs(fileName); err != nil {
log.Error("Can not generate file.", err)
ctx.Error(http.StatusBadRequest, ctx.Tr("repo.generate_statistic_file_error"))
return
}
ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(fileName))
ctx.Resp.Header().Set("Content-Type", "application/octet-stream")


ctx.ServeFile(fileName, url.QueryEscape(frontName))
f.WriteTo(ctx.Resp)


} }


func getFileName(ctx *context.Context, beginTime time.Time, endTime time.Time, projectAnalysis string) (string, string) {
func getFileName(ctx *context.Context, beginTime time.Time, endTime time.Time, projectAnalysis string) string {
baseName := setting.RadarMap.Path + "/" + projectAnalysis + "_" baseName := setting.RadarMap.Path + "/" + projectAnalysis + "_"


if ctx.QueryTrim("q") != "" { if ctx.QueryTrim("q") != "" {
@@ -229,23 +225,7 @@ func getFileName(ctx *context.Context, beginTime time.Time, endTime time.Time, p
baseName = baseName + beginTime.AddDate(0, 0, -1).Format(EXCEL_DATE_FORMAT) + "_" + endTime.AddDate(0, 0, -1).Format(EXCEL_DATE_FORMAT) baseName = baseName + beginTime.AddDate(0, 0, -1).Format(EXCEL_DATE_FORMAT) + "_" + endTime.AddDate(0, 0, -1).Format(EXCEL_DATE_FORMAT)
} }
frontName := baseName + ".xlsx" frontName := baseName + ".xlsx"
localName := baseName + "_" + strconv.FormatInt(time.Now().Unix(), 10) + ".xlsx"
return localName, path.Base(frontName)
}

func ClearUnusedStatisticsFile() {
fileInfos, err := ioutil.ReadDir(setting.RadarMap.Path)
if err != nil {
log.Warn("can not read dir: "+setting.RadarMap.Path, err)
return
}

for _, fileInfo := range fileInfos {
if !fileInfo.IsDir() && fileInfo.ModTime().Before(time.Now().AddDate(0, 0, -1)) {
os.Remove(path.Join(setting.RadarMap.Path, fileInfo.Name()))
}
}

return path.Base(frontName)
} }


func allProjectsPeroidHeader(ctx *context.Context) map[string]string { func allProjectsPeroidHeader(ctx *context.Context) map[string]string {


+ 5
- 4
web_src/js/components/ProAnalysis.vue View File

@@ -2,7 +2,7 @@
<div style="width: 100%;"> <div style="width: 100%;">
<div id = "pro_main"> <div id = "pro_main">
<div style="margin-top: 10px;"> <div style="margin-top: 10px;">
<b class="pro_item">项目分析</b> <span class="update_time">数据更新时间:{{lastUpdatedTime}}&nbsp/&nbsp从{{recordBeginTime}}开始统计</span>
<b class="pro_item">项目分析</b> <span class="update_time">数据更新时间:</span> <span style="font-size: 12px;">{{lastUpdatedTime}}&nbsp/&nbsp从{{recordBeginTime}}开始统计</span>
</div> </div>
<bar-label :width="'95%'" :height="'500px'"></bar-label> <bar-label :width="'95%'" :height="'500px'"></bar-label>
@@ -156,7 +156,7 @@
</div> </div>
<div id ="pro_detail" style="display:none;width: 100%;"> <div id ="pro_detail" style="display:none;width: 100%;">
<div style="margin-top: 10px;"> <div style="margin-top: 10px;">
<b class="pro_item">{{this.ownerName}}/{{this.pro_name}}</b> <span class="update_time">数据更新时间:{{tableDataIDTotal.lastUpdatedTime}}/{{tableDataIDTotal.recordBeginTime}}</span>
<b class="pro_item">{{this.ownerName}}/{{this.pro_name}}</b> <span class="update_time">数据更新时间:</span><span style="font-size: 12px;">{{tableDataIDTotal.lastUpdatedTime}}/{{tableDataIDTotal.recordBeginTime}}</span>
</div> </div>
<div style="margin-top: 10px;"> <div style="margin-top: 10px;">
项目描述:{{tableDataIDTotal.description | discriptionFun}} 项目描述:{{tableDataIDTotal.description | discriptionFun}}
@@ -1069,16 +1069,17 @@
height: 30px; height: 30px;
border-radius:4px ; border-radius:4px ;
} }
/*
.btn:focus, .btn:focus,
.btn:active{ .btn:active{
background-color:#409effd6 ; background-color:#409effd6 ;
}
} */
/deep/ .el-date-picker { /deep/ .el-date-picker {
width: 200px; width: 200px;
} }
.colorChange { .colorChange {
background-color: #409effd6; background-color: #409effd6;
color: #FFFF;
} }
.items{ .items{
text-align: center; text-align: center;


+ 5
- 4
web_src/js/components/UserAnalysis.vue View File

@@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<div style="margin-top: 10px;"> <div style="margin-top: 10px;">
<b class="pro_item">用户分析</b> <span class="update_time">数据更新时间:{{lastUpdatedTime}} &nbsp/&nbsp从{{recordBeginTime}}开始统计</span>
<b class="pro_item">用户分析</b> <span class="update_time">数据更新时间:</span><span style="font-size: 12px;">{{lastUpdatedTime}} &nbsp/&nbsp从{{recordBeginTime}}开始统计</span>
</div> </div>
<div style="margin-top: 20px;"> <div style="margin-top: 20px;">
<span class="sta_iterm">统计周期:</span> <span class="sta_iterm">统计周期:</span>
@@ -171,7 +171,7 @@
value_time: '', value_time: '',
search:'', search:'',
data:'', data:'',
columns: [{title: 'ID',key: 'ID'},{title: '用户名',key: 'Name'},{title: 'PR数',key: 'CommitCount'},{title: '提出任务数',key: 'IssueCount'},{title: '评论数',key: 'CommentCount'},{title: '关注项目数',key: 'FocusRepoCount'},{title: '点赞项目数',key: 'StarRepoCount'},{title: '登录次数',key: 'LoginCount'},{title:'关注者数',key:'WatchedCount'},{title:'commit代码行数',key:'CommitCodeSize'},{title:'已解决任务数',key:'SolveIssueCount'},{title:'百科页面贡献次数',key:'EncyclopediasCount'},{title:'创建项目',key:'CreateRepoCount'},{title:'用户注册时间',key:'RegistDate'},{title:'系统统计时间',key:'CountDate'}],
columns: [{title: 'ID',key: 'ID'},{title: '用户名',key: 'Name'},{title: 'PR数',key: 'CodeMergeCount'},{title: 'cimmit数',key:'CommitCount'},{title: '提出任务数',key: 'IssueCount'},{title: '评论数',key: 'CommentCount'},{title: '关注项目数',key: 'FocusRepoCount'},{title: '点赞项目数',key: 'StarRepoCount'},{title: '登录次数',key: 'LoginCount'},{title:'关注者数',key:'WatchedCount'},{title:'commit代码行数',key:'CommitCodeSize'},{title:'已解决任务数',key:'SolveIssueCount'},{title:'百科页面贡献次数',key:'EncyclopediasCount'},{title:'创建项目',key:'CreateRepoCount'},{title:'用户注册时间',key:'RegistDate'},{title:'系统统计时间',key:'CountDate'}],
blob:'', blob:'',
fileName:'', fileName:'',
dynamic:7, dynamic:7,
@@ -422,10 +422,10 @@
border-radius:4px ; border-radius:4px ;
} }


.btn:focus,
/* .btn:focus,
.btn:active{ .btn:active{
background-color:#409effd6 ; background-color:#409effd6 ;
}
} */
/deep/ .el-date-picker { /deep/ .el-date-picker {
width: 200px; width: 200px;
} }
@@ -435,6 +435,7 @@


.colorChange { .colorChange {
background-color: #409effd6; background-color: #409effd6;
color: #FFFF;
} }


</style> </style>

Loading…
Cancel
Save