111111111111111111111111111111111111pull/883/head
@@ -674,5 +674,8 @@ func subMonth(t1, t2 time.Time) (month int) { | |||
} | |||
monthInterval %= 12 | |||
month = yearInterval*12 + monthInterval | |||
if month == 0 { | |||
month = 1 | |||
} | |||
return month | |||
} |
@@ -11,7 +11,6 @@ import ( | |||
"code.gitea.io/gitea/models" | |||
"code.gitea.io/gitea/modules/migrations" | |||
repository_service "code.gitea.io/gitea/modules/repository" | |||
api_repo "code.gitea.io/gitea/routers/api/v1/repo" | |||
"code.gitea.io/gitea/routers/repo" | |||
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() { | |||
registerUpdateMirrorTask() | |||
registerRepoHealthCheck() | |||
@@ -2,7 +2,6 @@ package repo | |||
import ( | |||
"fmt" | |||
"io/ioutil" | |||
"net/http" | |||
"net/url" | |||
"os" | |||
@@ -174,7 +173,7 @@ func ServeAllProjectsPeriodStatisticsFile(ctx *context.Context) { | |||
return | |||
} | |||
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 { | |||
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.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 + "_" | |||
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) | |||
} | |||
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 { | |||
@@ -2,7 +2,7 @@ | |||
<div style="width: 100%;"> | |||
<div id = "pro_main"> | |||
<div style="margin-top: 10px;"> | |||
<b class="pro_item">项目分析</b> <span class="update_time">数据更新时间:{{lastUpdatedTime}} / 从{{recordBeginTime}}开始统计</span> | |||
<b class="pro_item">项目分析</b> <span class="update_time">数据更新时间:</span> <span style="font-size: 12px;">{{lastUpdatedTime}} / 从{{recordBeginTime}}开始统计</span> | |||
</div> | |||
<bar-label :width="'95%'" :height="'500px'"></bar-label> | |||
@@ -156,7 +156,7 @@ | |||
</div> | |||
<div id ="pro_detail" style="display:none;width: 100%;"> | |||
<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 style="margin-top: 10px;"> | |||
项目描述:{{tableDataIDTotal.description | discriptionFun}} | |||
@@ -1069,16 +1069,17 @@ | |||
height: 30px; | |||
border-radius:4px ; | |||
} | |||
/* | |||
.btn:focus, | |||
.btn:active{ | |||
background-color:#409effd6 ; | |||
} | |||
} */ | |||
/deep/ .el-date-picker { | |||
width: 200px; | |||
} | |||
.colorChange { | |||
background-color: #409effd6; | |||
color: #FFFF; | |||
} | |||
.items{ | |||
text-align: center; | |||
@@ -1,7 +1,7 @@ | |||
<template> | |||
<div> | |||
<div style="margin-top: 10px;"> | |||
<b class="pro_item">用户分析</b> <span class="update_time">数据更新时间:{{lastUpdatedTime}}  / 从{{recordBeginTime}}开始统计</span> | |||
<b class="pro_item">用户分析</b> <span class="update_time">数据更新时间:</span><span style="font-size: 12px;">{{lastUpdatedTime}}  / 从{{recordBeginTime}}开始统计</span> | |||
</div> | |||
<div style="margin-top: 20px;"> | |||
<span class="sta_iterm">统计周期:</span> | |||
@@ -171,7 +171,7 @@ | |||
value_time: '', | |||
search:'', | |||
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:'', | |||
fileName:'', | |||
dynamic:7, | |||
@@ -422,10 +422,10 @@ | |||
border-radius:4px ; | |||
} | |||
.btn:focus, | |||
/* .btn:focus, | |||
.btn:active{ | |||
background-color:#409effd6 ; | |||
} | |||
} */ | |||
/deep/ .el-date-picker { | |||
width: 200px; | |||
} | |||
@@ -435,6 +435,7 @@ | |||
.colorChange { | |||
background-color: #409effd6; | |||
color: #FFFF; | |||
} | |||
</style> |