From 4eb86a5d9cd367f3dabfac6ed51320a8864185a7 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Fri, 22 Apr 2022 14:22:47 +0800 Subject: [PATCH 001/188] =?UTF-8?q?fix-1937=E5=90=8E=E7=AB=AF=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/repo.go | 5 + models/summary_statistic.go | 34 +++ options/locale/locale_en-US.ini | 11 + options/locale/locale_zh-CN.ini | 12 + routers/api/v1/api.go | 3 + routers/api/v1/repo/repo_dashbord.go | 313 +++++++++++++++++++++++++ routers/repo/repo_summary_statistic.go | 7 + 7 files changed, 385 insertions(+) diff --git a/models/repo.go b/models/repo.go index 25bfb4a74..db2694617 100755 --- a/models/repo.go +++ b/models/repo.go @@ -1554,6 +1554,11 @@ func GetAllMirrorRepositoriesCount() (int64, error) { return x.Where("is_mirror = ?", true).Count(repo) } +func GetAllOrgRepositoriesCount() (int64, error) { + repo := new(Repository) + return x.Table("repository").Join("INNER", []string{"\"user\"", "u"}, "repository.owner_id = u.id and u.type=1").Count(repo) +} + func GetAllForkRepositoriesCount() (int64, error) { repo := new(Repository) return x.Where("is_fork = ?", true).Count(repo) diff --git a/models/summary_statistic.go b/models/summary_statistic.go index e5cf54b75..7787aa292 100644 --- a/models/summary_statistic.go +++ b/models/summary_statistic.go @@ -2,6 +2,8 @@ package models import ( "fmt" + "strconv" + "time" "code.gitea.io/gitea/modules/timeutil" ) @@ -45,6 +47,7 @@ type SummaryStatistic struct { NumRepoFork int64 `xorm:"NOT NULL DEFAULT 0"` NumRepoMirror int64 `xorm:"NOT NULL DEFAULT 0"` NumRepoSelf int64 `xorm:"NOT NULL DEFAULT 0"` + NumRepoOrg int64 `xorm:"NOT NULL DEFAULT 0"` CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` } @@ -69,6 +72,37 @@ func DeleteSummaryStatisticDaily(date string) error { return nil } +func GetLatest2SummaryStatistic() ([]*SummaryStatistic, error) { + summaryStatistics := make([]*SummaryStatistic, 0) + err := xStatistic.Desc("created_unix").Limit(2).Find(&summaryStatistics) + return summaryStatistics, err +} + +func GetSummaryStatisticByTimeCount(beginTime time.Time, endTime time.Time) (int64, error) { + summaryStatistics := new(SummaryStatistic) + total, err := xStatistic.Asc("created_unix").Where("created_unix>=" + strconv.FormatInt(beginTime.Unix(), 10) + " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10)).Count(summaryStatistics) + return total, err +} + +func GetSummaryStatisticByDateCount(dates []string) (int64, error) { + summaryStatistics := new(SummaryStatistic) + total, err := xStatistic.Asc("created_unix").In("date", dates).Count(summaryStatistics) + return total, err +} + +func GetSummaryStatisticByTime(beginTime time.Time, endTime time.Time, page int, pageSize int) ([]*SummaryStatistic, error) { + summaryStatistics := make([]*SummaryStatistic, 0) + err := xStatistic.Asc("created_unix").Limit(pageSize+1, (page-1)*pageSize).Where("created_unix>=" + strconv.FormatInt(beginTime.Unix(), 10) + " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10)).Find(&summaryStatistics) + + return summaryStatistics, err +} + +func GetSummaryStatisticByDates(dates []string, page int, pageSize int) ([]*SummaryStatistic, error) { + summaryStatistics := make([]*SummaryStatistic, 0) + err := xStatistic.Asc("created_unix").In("date", dates).Limit(pageSize+1, (page-1)*pageSize).Find(&summaryStatistics) + return summaryStatistics, err +} + func InsertSummaryStatistic(summaryStatistic *SummaryStatistic) (int64, error) { return xStatistic.Insert(summaryStatistic) } diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index f53bea7b1..6d1ac24c7 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -937,6 +937,15 @@ model_manager = Model model_noright=No right model_rename=Duplicate model name, please modify model name. +date=Date +repo_add=Project Increment +repo_total=Project Total +repo_public_add=Public Project Increment +repo_private_add=Private Project Increment +repo_fork_add=Fork Project Increment +repo_mirror_add=Mirror Project Increment +repo_self_add=Custom Project Increment + debug=Debug debug_again=Restart stop=Stop @@ -1001,7 +1010,9 @@ 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=Failed to generate file. repo_stat_inspect=ProjectAnalysis +repo_stat_develop=ProjectGrowthAnalysis all=All +current_year=Current_Year computing.all = All computing.Introduction=Introduction diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index c82347d5e..2232c36a1 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -938,6 +938,16 @@ model_manager = 模型 model_noright=无权限操作 model_rename=模型名称重复,请修改模型名称 + +date=日期 +repo_add=新增项目 +repo_total=累计项目 +repo_public_add=新增公开项目 +repo_private_add=新增私有项目 +repo_fork_add=新增派生项目 +repo_mirror_add=新增镜像项目 +repo_self_add=新增自建项目 + debug=调试 debug_again=再次调试 stop=停止 @@ -1009,7 +1019,9 @@ get_repo_stat_error=查询当前仓库的统计信息失败。 get_repo_info_error=查询当前仓库信息失败。 generate_statistic_file_error=生成文件失败。 repo_stat_inspect=项目分析 +repo_stat_develop=项目增长趋势 all=所有 +current_year=今年 computing.all=全部 computing.Introduction=简介 diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 2b070a4b8..3cc1a6693 100755 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -535,6 +535,9 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/restoreFork", repo.RestoreForkNumber) m.Get("/downloadAll", repo.ServeAllProjectsPeriodStatisticsFile) m.Get("/downloadAllOpenI", repo.ServeAllProjectsOpenIStatisticsFile) + m.Get("/summary", repo.GetLatestProjectsSummaryData) + m.Get("/summary/period", repo.GetProjectsSummaryData) + m.Get("/summary/download", repo.GetProjectsSummaryDataFile) m.Group("/project", func() { m.Get("", repo.GetAllProjectsPeriodStatistics) m.Get("/numVisit", repo.ProjectNumVisit) diff --git a/routers/api/v1/repo/repo_dashbord.go b/routers/api/v1/repo/repo_dashbord.go index 2c42f8a16..7ec315fd9 100644 --- a/routers/api/v1/repo/repo_dashbord.go +++ b/routers/api/v1/repo/repo_dashbord.go @@ -20,8 +20,10 @@ import ( const DEFAULT_PAGE_SIZE = 10 const DATE_FORMAT = "2006-01-02" +const MONTH_FORMAT = "2006-01" const EXCEL_DATE_FORMAT = "20060102" const CREATE_TIME_FORMAT = "2006/01/02 15:04:05" +const UPDATE_TIME_FORMAT = "2006-01-02 15:04:05" type ProjectsPeriodData struct { RecordBeginTime string `json:"recordBeginTime"` @@ -60,6 +62,40 @@ type ProjectLatestData struct { Top10 []UserInfo `json:"top10"` } +type ProjectSummaryBaseData struct { + NumReposAdd int64 `json:"numReposAdd"` + NumRepoPublicAdd int64 `json:"numRepoPublicAdd"` + NumRepoPrivateAdd int64 `json:"numRepoPrivateAdd"` + NumRepoForkAdd int64 `json:"numRepoForkAdd"` + NumRepoMirrorAdd int64 `json:"numRepoMirrorAdd"` + NumRepoSelfAdd int64 `json:"numRepoSelfAdd"` + NumRepos int64 `json:"numRepos"` + CreatTime string `json:"creatTime"` +} + +type ProjectSummaryData struct { + ProjectSummaryBaseData + NumRepoPublic int64 `json:"numRepoPublic"` + NumRepoPrivate int64 `json:"numRepoPrivate"` + NumRepoFork int64 `json:"numRepoFork"` + NumRepoMirror int64 `json:"numRepoMirror"` + NumRepoSelf int64 `json:"numRepoSelf"` + + NumRepoOrgAdd int64 `json:"numRepoOrgAdd"` + NumRepoNotOrgAdd int64 `json:"numRepoNotOrgAdd"` + + NumRepoOrg int64 `json:"numRepoOrg"` + NumRepoNotOrg int64 `json:"numRepoNotOrg"` +} + +type ProjectSummaryPeriodData struct { + RecordBeginTime string `json:"recordBeginTime"` + PageSize int `json:"pageSize"` + TotalPage int `json:"totalPage"` + TotalCount int64 `json:"totalCount"` + PageRecords []*ProjectSummaryBaseData `json:"pageRecords"` +} + func RestoreForkNumber(ctx *context.Context) { repos, err := models.GetAllRepositories() if err != nil { @@ -73,6 +109,144 @@ func RestoreForkNumber(ctx *context.Context) { ctx.JSON(http.StatusOK, struct{}{}) } +func GetLatestProjectsSummaryData(ctx *context.Context) { + stat, err := models.GetLatest2SummaryStatistic() + data := ProjectSummaryData{} + if err == nil && len(stat) > 0 { + data.NumRepos = stat[0].NumRepos + data.NumRepoOrg = stat[0].NumRepoOrg + data.NumRepoNotOrg = stat[0].NumRepos - stat[0].NumRepoOrg + data.NumRepoFork = stat[0].NumRepoFork + data.NumRepoMirror = stat[0].NumRepoMirror + data.NumRepoSelf = stat[0].NumRepoSelf + data.NumRepoPrivate = stat[0].NumRepoPrivate + data.NumRepoPublic = stat[0].NumRepoPublic + data.CreatTime = stat[0].CreatedUnix.Format(UPDATE_TIME_FORMAT) + if len(stat) == 2 { + data.NumReposAdd = stat[0].NumRepos - stat[1].NumRepos + data.NumRepoOrgAdd = stat[0].NumRepoOrg - stat[1].NumRepoOrg + data.NumRepoNotOrgAdd = (stat[0].NumRepos - stat[0].NumRepoOrg) - (stat[1].NumRepos - stat[1].NumRepoOrg) + data.NumRepoForkAdd = stat[0].NumRepoFork - stat[1].NumRepoFork + data.NumRepoMirrorAdd = stat[0].NumRepoMirror - stat[1].NumRepoMirror + data.NumRepoSelfAdd = stat[0].NumRepoSelf - stat[1].NumRepoSelf + data.NumRepoPrivateAdd = stat[0].NumRepoPrivate - stat[1].NumRepoPrivate + data.NumRepoPublicAdd = stat[0].NumRepoPublic - stat[1].NumRepoPublic + } + } + ctx.JSON(200, data) +} + +func GetProjectsSummaryData(ctx *context.Context) { + + var datas = make([]*ProjectSummaryBaseData, 0) + + recordBeginTime, err := getRecordBeginTime() + if err != nil { + log.Error("Can not get record begin time", err) + ctx.Error(http.StatusBadRequest, ctx.Tr("repo.record_begintime_get_err")) + return + } + beginTime, endTime, err := getTimePeroid(ctx, recordBeginTime) + + beginTime = beginTime.AddDate(0, 0, -1) + + queryType := ctx.QueryTrim("type") + + page := ctx.QueryInt("page") + if page <= 0 { + page = 1 + } + pageSize := ctx.QueryInt("pagesize") + if pageSize <= 0 { + pageSize = DEFAULT_PAGE_SIZE + } + var count int64 + + if queryType == "all" || queryType == "current_year" { + dates := getEndOfMonthDates(beginTime, endTime) + count, _ = models.GetSummaryStatisticByDateCount(dates) + stats, err := models.GetSummaryStatisticByDates(dates, page, pageSize) + if err != nil { + log.Warn("can not get summary data", err) + } else { + + for i, v := range stats { + if i == 0 { + continue + } + data := ProjectSummaryBaseData{} + setStatisticsData(&data, v, stats[i-1]) + createTime, _ := time.Parse(DATE_FORMAT, v.Date) + data.CreatTime = createTime.Format(MONTH_FORMAT) + datas = append(datas, &data) + } + } + + } else { + count, _ = models.GetSummaryStatisticByTimeCount(beginTime, endTime) + stats, err := models.GetSummaryStatisticByTime(beginTime, endTime, page, pageSize) + if err != nil { + log.Warn("can not get summary data", err) + } else { + + for i, v := range stats { + if i == 0 { + continue + } + data := ProjectSummaryBaseData{} + setStatisticsData(&data, v, stats[i-1]) + data.CreatTime = v.Date + datas = append(datas, &data) + } + } + + } + projectSummaryPeriodData := ProjectSummaryPeriodData{ + TotalCount: count - 1, + TotalPage: getTotalPage(count-1, pageSize), + RecordBeginTime: recordBeginTime.Format(DATE_FORMAT), + PageSize: pageSize, + PageRecords: datas, + } + + ctx.JSON(200, projectSummaryPeriodData) + +} + +func setStatisticsData(data *ProjectSummaryBaseData, v *models.SummaryStatistic, stats *models.SummaryStatistic) { + data.NumReposAdd = v.NumRepos - stats.NumRepos + data.NumRepoPublicAdd = v.NumRepoPublic - stats.NumRepoPublic + data.NumRepoPrivateAdd = v.NumRepoPrivate - stats.NumRepoPrivate + data.NumRepoMirrorAdd = v.NumRepoMirror - stats.NumRepoMirror + data.NumRepoForkAdd = v.NumRepoFork - stats.NumRepoFork + data.NumRepoSelfAdd = v.NumRepoSelf - stats.NumRepoSelf + + data.NumRepos = v.NumRepos +} + +func getEndOfMonthDates(beginTime time.Time, endTime time.Time) []string { + var dates = []string{} + date := endOfMonth(beginTime.AddDate(0, -1, 0)) + dates = append(dates, date.Format(DATE_FORMAT)) + + tempDate := endOfMonth(beginTime) + + for { + if tempDate.Before(endTime) { + dates = append(dates, tempDate.Format(DATE_FORMAT)) + tempDate = endOfMonth(tempDate.AddDate(0, 0, 1)) + } else { + break + } + } + + return dates +} + +func endOfMonth(date time.Time) time.Time { + return date.AddDate(0, 1, -date.Day()) +} + func GetAllProjectsPeriodStatistics(ctx *context.Context) { recordBeginTime, err := getRecordBeginTime() @@ -210,6 +384,118 @@ func ServeAllProjectsPeriodStatisticsFile(ctx *context.Context) { } +func GetProjectsSummaryDataFile(ctx *context.Context) { + + recordBeginTime, err := getRecordBeginTime() + if err != nil { + log.Error("Can not get record begin time", err) + ctx.Error(http.StatusBadRequest, ctx.Tr("repo.record_begintime_get_err")) + return + } + beginTime, endTime, err := getTimePeroid(ctx, recordBeginTime) + beginTime = beginTime.AddDate(0, 0, -1) + if err != nil { + log.Error("Parameter is wrong", err) + ctx.Error(http.StatusBadRequest, ctx.Tr("repo.parameter_is_wrong")) + return + } + + page := ctx.QueryInt("page") + if page <= 0 { + page = 1 + } + pageSize := 100 + + if err != nil { + log.Error("Can not query the last updated time.", err) + ctx.Error(http.StatusBadRequest, ctx.Tr("repo.last_update_time_error")) + return + } + + var projectAnalysis = ctx.Tr("repo.repo_stat_develop") + fileName := getSummaryFileName(ctx, beginTime, endTime, projectAnalysis) + + f := excelize.NewFile() + + index := f.NewSheet(projectAnalysis) + f.DeleteSheet("Sheet1") + + for k, v := range allProjectsPeriodSummaryHeader(ctx) { + f.SetCellValue(projectAnalysis, k, v) + } + + var total int64 + queryType := ctx.QueryTrim("type") + row := 2 + + if queryType == "all" || queryType == "current_year" { + dates := getEndOfMonthDates(beginTime, endTime) + total, _ = models.GetSummaryStatisticByDateCount(dates) + totalPage := getTotalPage(total, pageSize) + + for i := 0; i < totalPage; i++ { + + stats, err := models.GetSummaryStatisticByDates(dates, i+1, pageSize) + if err != nil { + log.Warn("can not get summary data", err) + } else { + for j, v := range stats { + if j == 0 { + continue + } + data := ProjectSummaryBaseData{} + setStatisticsData(&data, v, stats[j-1]) + createTime, _ := time.Parse(DATE_FORMAT, v.Date) + data.CreatTime = createTime.Format(MONTH_FORMAT) + + for k, v := range allProjectsPeriodSummaryValues(row, &data, ctx) { + f.SetCellValue(projectAnalysis, k, v) + } + row++ + } + + } + + } + + } else { + total, _ = models.GetSummaryStatisticByTimeCount(beginTime, endTime) + totalPage := getTotalPage(total, pageSize) + + for i := 0; i < totalPage; i++ { + + stats, err := models.GetSummaryStatisticByTime(beginTime, endTime, i+1, pageSize) + if err != nil { + log.Warn("can not get summary data", err) + } else { + for j, v := range stats { + if j == 0 { + continue + } + data := ProjectSummaryBaseData{} + setStatisticsData(&data, v, stats[j-1]) + data.CreatTime = v.Date + + for k, v := range allProjectsPeriodSummaryValues(row, &data, ctx) { + f.SetCellValue(projectAnalysis, k, v) + } + row++ + } + + } + + } + } + + f.SetActiveSheet(index) + + ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(fileName)) + ctx.Resp.Header().Set("Content-Type", "application/octet-stream") + + f.WriteTo(ctx.Resp) + +} + func ServeAllProjectsOpenIStatisticsFile(ctx *context.Context) { page := ctx.QueryInt("page") @@ -290,6 +576,20 @@ func getFileName(ctx *context.Context, beginTime time.Time, endTime time.Time, p return frontName } +func getSummaryFileName(ctx *context.Context, beginTime time.Time, endTime time.Time, projectAnalysis string) string { + baseName := projectAnalysis + "_" + + if ctx.QueryTrim("type") == "all" { + baseName = baseName + ctx.Tr("repo.all") + } else if ctx.QueryTrim("type") == "current_year" { + baseName = baseName + ctx.Tr("repo.current_year") + } else { + baseName = baseName + beginTime.Format(EXCEL_DATE_FORMAT) + "_" + endTime.AddDate(0, 0, -1).Format(EXCEL_DATE_FORMAT) + } + frontName := baseName + ".xlsx" + return frontName +} + func allProjectsPeroidHeader(ctx *context.Context) map[string]string { return map[string]string{"A1": ctx.Tr("admin.repos.id"), "B1": ctx.Tr("admin.repos.projectName"), "C1": ctx.Tr("repo.owner"), "D1": ctx.Tr("admin.repos.isPrivate"), "E1": ctx.Tr("admin.repos.openi"), "F1": ctx.Tr("admin.repos.visit"), "G1": ctx.Tr("admin.repos.download"), "H1": ctx.Tr("admin.repos.pr"), "I1": ctx.Tr("admin.repos.commit"), @@ -297,6 +597,19 @@ func allProjectsPeroidHeader(ctx *context.Context) map[string]string { } +func allProjectsPeriodSummaryHeader(ctx *context.Context) map[string]string { + + return map[string]string{"A1": ctx.Tr("repo.date"), "B1": ctx.Tr("repo.repo_add"), "C1": ctx.Tr("repo.repo_total"), "D1": ctx.Tr("repo.repo_public_add"), "E1": ctx.Tr("repo.repo_private_add"), "F1": ctx.Tr("repo.repo_self_add"), "G1": ctx.Tr("repo.repo_fork_add"), "H1": ctx.Tr("repo.repo_mirror_add")} + +} + +func allProjectsPeriodSummaryValues(row int, rs *ProjectSummaryBaseData, ctx *context.Context) map[string]string { + + return map[string]string{getCellName("A", row): rs.CreatTime, getCellName("B", row): strconv.FormatInt(rs.NumReposAdd, 10), getCellName("C", row): strconv.FormatInt(rs.NumRepos, 10), getCellName("D", row): strconv.FormatInt(rs.NumRepoPublicAdd, 10), getCellName("E", row): strconv.FormatInt(rs.NumRepoPrivateAdd, 10), + getCellName("F", row): strconv.FormatInt(rs.NumRepoSelfAdd, 10), getCellName("G", row): strconv.FormatInt(rs.NumRepoForkAdd, 10), getCellName("H", row): strconv.FormatInt(rs.NumRepoMirrorAdd, 10), + } +} + func allProjectsPeroidValues(row int, rs *models.RepoStatistic, ctx *context.Context) map[string]string { return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.DisplayName(), getCellName("C", row): rs.OwnerName, getCellName("D", row): getBoolDisplay(rs.IsPrivate, ctx), getCellName("E", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), getCellName("F", row): strconv.FormatInt(rs.NumVisits, 10), getCellName("G", row): strconv.FormatInt(rs.NumDownloads, 10), getCellName("H", row): strconv.FormatInt(rs.NumPulls, 10), getCellName("I", row): strconv.FormatInt(rs.NumCommits, 10), diff --git a/routers/repo/repo_summary_statistic.go b/routers/repo/repo_summary_statistic.go index 3af31737c..65ba2cf0b 100644 --- a/routers/repo/repo_summary_statistic.go +++ b/routers/repo/repo_summary_statistic.go @@ -60,6 +60,12 @@ func SummaryStatisticDaily(date string) { } selfRepositoryNumber := repositoryNumer - mirrorRepositoryNumber - forkRepositoryNumber + organizationRepoNumber, err := models.GetAllOrgRepositoriesCount() + if err != nil { + log.Error("can not get org repository number", err) + organizationRepoNumber = 0 + } + //repository size repositorySize, err := models.GetAllRepositoriesSize() if err != nil { @@ -99,6 +105,7 @@ func SummaryStatisticDaily(date string) { NumRepoPrivate: privateRepositoryNumer, NumRepoPublic: publicRepositoryNumer, NumRepoSelf: selfRepositoryNumber, + NumRepoOrg: organizationRepoNumber, NumRepoBigModel: topicsCount[0], NumRepoAI: topicsCount[1], NumRepoVision: topicsCount[2], From 5cecfa5159029e19f841bc4507c6a5da1a5d30e5 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 28 Apr 2022 15:37:28 +0800 Subject: [PATCH 002/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82=E7=94=A8=E6=88=B7=E7=BB=9F=E8=AE=A1=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/dbsql/repo_foreigntable_for_es.sql | 10 +- models/user_business_analysis.go | 144 +++++++++++++++++++++- models/user_business_struct.go | 17 ++- options/locale/locale_zh-CN.ini | 13 ++ routers/repo/user_data_analysis.go | 82 +++++++++++- 5 files changed, 247 insertions(+), 19 deletions(-) diff --git a/models/dbsql/repo_foreigntable_for_es.sql b/models/dbsql/repo_foreigntable_for_es.sql index 7e06fd99e..e927eb7c2 100644 --- a/models/dbsql/repo_foreigntable_for_es.sql +++ b/models/dbsql/repo_foreigntable_for_es.sql @@ -523,17 +523,21 @@ DROP TRIGGER IF EXISTS es_udpate_repository_lang on public.language_stat; CREATE OR REPLACE FUNCTION public.udpate_repository_lang() RETURNS trigger AS $def$ + DECLARE + privateValue bigint; BEGIN if (TG_OP = 'UPDATE') then - update public.repository_es SET lang=(select array_to_string(array_agg(language order by percentage desc),',') from public.language_stat where repo_id=NEW.repo_id) where id=NEW.repo_id; + select into privateValue updated_unix from public.repository where id=NEW.repo_id; + update public.repository_es SET updated_unix=privateValue,lang=(select array_to_string(array_agg(language order by percentage desc),',') from public.language_stat where repo_id=NEW.repo_id) where id=NEW.repo_id; elsif (TG_OP = 'INSERT') then - update public.repository_es SET lang=(select array_to_string(array_agg(language order by percentage desc),',') from public.language_stat where repo_id=NEW.repo_id) where id=NEW.repo_id; + select into privateValue updated_unix from public.repository where id=NEW.repo_id; + update public.repository_es SET updated_unix=privateValue,lang=(select array_to_string(array_agg(language order by percentage desc),',') from public.language_stat where repo_id=NEW.repo_id) where id=NEW.repo_id; elsif (TG_OP = 'DELETE') then if exists(select 1 from public.repository where id=OLD.repo_id) then update public.repository_es SET lang=(select array_to_string(array_agg(language order by percentage desc),',') from public.language_stat where repo_id=OLD.repo_id) where id=OLD.repo_id; end if; end if; - return null; + return NEW; END; $def$ LANGUAGE plpgsql; diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 2d7592baf..7e9e877c2 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -4,6 +4,7 @@ import ( "fmt" "sort" "strconv" + "strings" "time" "code.gitea.io/gitea/modules/log" @@ -103,6 +104,8 @@ type UserBusinessAnalysisAll struct { CollectImage int `xorm:"NOT NULL DEFAULT 0"` CollectedImage int `xorm:"NOT NULL DEFAULT 0"` RecommendImage int `xorm:"NOT NULL DEFAULT 0"` + + HasActivity int `xorm:"NOT NULL DEFAULT 0"` } type UserBusinessAnalysis struct { @@ -190,6 +193,8 @@ type UserBusinessAnalysis struct { CollectImage int `xorm:"NOT NULL DEFAULT 0"` CollectedImage int `xorm:"NOT NULL DEFAULT 0"` RecommendImage int `xorm:"NOT NULL DEFAULT 0"` + + HasActivity int `xorm:"NOT NULL DEFAULT 0"` } type UserBusinessAnalysisQueryOptions struct { @@ -227,15 +232,93 @@ func getLastCountDate() int64 { return pageStartTime.Unix() } -func QueryMetrics(start int64, end int64) ([]*UserMetrics, int64) { +func QueryMetricsPage(start int64, end int64, page int, pageSize int) ([]UserMetrics, int64) { + + statictisSess := xStatistic.NewSession() + defer statictisSess.Close() + cond := "count_date >" + fmt.Sprint(start) + " and count_date<" + fmt.Sprint(end) + allCount, err := statictisSess.Where(cond).Count(new(UserMetrics)) + if err != nil { + log.Info("query error." + err.Error()) + return nil, 0 + } + userMetricsList := make([]UserMetrics, 0) + if err := statictisSess.Table(new(UserMetrics)).Where(cond).Limit(pageSize, page*pageSize).OrderBy("count_date desc"). + Find(&userMetricsList); err != nil { + return nil, 0 + } + return userMetricsList, allCount + +} + +func QueryMetrics(start int64, end int64) ([]UserMetrics, int) { statictisSess := xStatistic.NewSession() defer statictisSess.Close() - userMetricsList := make([]*UserMetrics, 0) + userMetricsList := make([]UserMetrics, 0) if err := statictisSess.Table(new(UserMetrics)).Where("count_date >" + fmt.Sprint(start) + " and count_date<" + fmt.Sprint(end)).OrderBy("count_date desc"). Find(&userMetricsList); err != nil { return nil, 0 } - return userMetricsList, int64(len(userMetricsList)) + return userMetricsList, len(userMetricsList) +} + +func QueryMetricsForAll() []UserMetrics { + statictisSess := xStatistic.NewSession() + defer statictisSess.Close() + userMetricsList := make([]UserMetrics, 0) + if err := statictisSess.Table(new(UserMetrics)).OrderBy("count_date desc"). + Find(&userMetricsList); err != nil { + return nil + } + return makeResultForMonth(userMetricsList, len(userMetricsList)) +} + +func QueryMetricsForYear() []UserMetrics { + currentTimeNow := time.Now() + currentYearEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) + currentYearStartTime := time.Date(currentTimeNow.Year(), 1, 1, 0, 0, 0, 0, currentTimeNow.Location()) + allUserInfo, count := QueryMetrics(currentYearStartTime.Unix(), currentYearEndTime.Unix()) + + return makeResultForMonth(allUserInfo, count) +} + +func makeResultForMonth(allUserInfo []UserMetrics, count int) []UserMetrics { + monthMap := make(map[string]UserMetrics) + if count > 0 { + for _, userMetrics := range allUserInfo { + dateTime := time.Unix(userMetrics.CountDate, 0) + month := fmt.Sprint(dateTime.Year()) + "-" + fmt.Sprint(int(dateTime.Month())) + if _, ok := monthMap[month]; !ok { + var monthUserMetrics UserMetrics + monthUserMetrics.DisplayDate = month + monthUserMetrics.ActivateRegistUser = userMetrics.ActivateRegistUser + monthUserMetrics.NotActivateRegistUser = userMetrics.NotActivateRegistUser + monthUserMetrics.TotalUser = userMetrics.TotalUser + monthUserMetrics.TotalActivateRegistUser = userMetrics.TotalActivateRegistUser + monthUserMetrics.TotalHasActivityUser = userMetrics.TotalHasActivityUser + monthUserMetrics.HasActivityUser = userMetrics.HasActivityUser + monthUserMetrics.DaysForMonth = 1 + monthMap[month] = monthUserMetrics + } else { + value := monthMap[month] + value.ActivateRegistUser += userMetrics.ActivateRegistUser + value.NotActivateRegistUser += userMetrics.NotActivateRegistUser + value.TotalUser += userMetrics.TotalUser + value.TotalActivateRegistUser += userMetrics.TotalActivateRegistUser + value.TotalHasActivityUser += userMetrics.TotalHasActivityUser + value.HasActivityUser += userMetrics.HasActivityUser + value.DaysForMonth += 1 + } + } + } + result := make([]UserMetrics, 0) + for _, value := range monthMap { + result = append(result, value) + } + sort.Slice(result, func(i, j int) bool { + return strings.Compare(result[i].DisplayDate, result[j].DisplayDate) > 0 + }) + return result } func QueryRankList(key string, tableName string, limit int) ([]*UserBusinessAnalysisAll, int64) { @@ -540,6 +623,7 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS if minUserIndex > dateRecordAll.UserIndexPrimitive { minUserIndex = dateRecordAll.UserIndexPrimitive } + dateRecordBatch = append(dateRecordBatch, dateRecordAll) if len(dateRecordBatch) >= BATCH_INSERT_SIZE { insertTable(dateRecordBatch, tableName, statictisSess) @@ -695,7 +779,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, log.Info("query user error. return.") return err } - + userNewAddActivity := make(map[int64]map[int64]int64) ParaWeight := getParaWeight() userMetrics := make(map[string]int) var indexTotal int64 @@ -767,6 +851,9 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, dateRecord.UserIndexPrimitive = getUserIndex(dateRecord, ParaWeight) setUserMetrics(userMetrics, userRecord, start_unix, end_unix, dateRecord) + if getUserActivate(dateRecord) > 0 { + addUserToMap(userNewAddActivity, userRecord.CreatedUnix, dateRecord.ID) + } _, err = statictisSess.Insert(&dateRecord) if err != nil { log.Info("insert daterecord failed." + err.Error()) @@ -792,11 +879,58 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, useMetrics.NotActivateRegistUser = getMapKeyStringValue("NotActivateRegistUser", userMetrics) useMetrics.TotalActivateRegistUser = getMapKeyStringValue("TotalActivateRegistUser", userMetrics) useMetrics.TotalHasActivityUser = getMapKeyStringValue("TotalHasActivityUser", userMetrics) - statictisSess.Insert(&useMetrics) + count, err = sess.Count(new(User)) + if err != nil { + log.Info("query user error. return.") + } + useMetrics.TotalUser = int(count) + useMetrics.ActivateIIndex = float64(useMetrics.ActivateRegistUser) / float64(useMetrics.ActivateRegistUser+useMetrics.NotActivateRegistUser) + statictisSess.Insert(&useMetrics) + //update new user activity + updateNewUserAcitivity(userNewAddActivity, statictisSess) return nil } +func updateNewUserAcitivity(currentUserActivity map[int64]map[int64]int64, statictisSess *xorm.Session) { + for key, value := range currentUserActivity { + useMetrics := &UserMetrics{CountDate: key} + has, err := statictisSess.Get(useMetrics) + if err == nil && has { + userIdArrays := strings.Split(useMetrics.HasActivityUserJson, ",") + for _, userIdStr := range userIdArrays { + userIdInt, err := strconv.ParseInt(userIdStr, 10, 64) + if err == nil { + value[userIdInt] = userIdInt + } + } + userIdArray := "" + for _, tmpValue := range value { + userIdArray += fmt.Sprint(tmpValue) + "," + } + useMetrics.HasActivityUser = len(value) + if len(userIdArray) > 0 { + useMetrics.HasActivityUserJson = userIdArray[0 : len(userIdArray)-1] + + } + statictisSess.Update(useMetrics) + } + } +} + +func addUserToMap(currentUserActivity map[int64]map[int64]int64, registDate timeutil.TimeStamp, userId int64) { + CountDateTime := time.Date(registDate.Year(), registDate.AsTime().Month(), registDate.AsTime().Day(), 0, 1, 0, 0, registDate.AsTime().Location()) + CountDate := CountDateTime.Unix() + if _, ok := currentUserActivity[CountDate]; !ok { + userIdMap := make(map[int64]int64, 0) + userIdMap[userId] = userId + currentUserActivity[CountDate] = userIdMap + } else { + currentUserActivity[CountDate][userId] = userId + } + +} + func setUserMetrics(userMetrics map[string]int, user *User, start_time int64, end_time int64, dateRecord UserBusinessAnalysis) { //ActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` //NotActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` diff --git a/models/user_business_struct.go b/models/user_business_struct.go index 86aecd545..5560cb19a 100644 --- a/models/user_business_struct.go +++ b/models/user_business_struct.go @@ -400,10 +400,15 @@ type UserAnalysisPara struct { } type UserMetrics struct { - CountDate int64 `xorm:"pk"` - ActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` - NotActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` - HasActivityUser int `xorm:"NOT NULL DEFAULT 0"` - TotalActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` - TotalHasActivityUser int `xorm:"NOT NULL DEFAULT 0"` + CountDate int64 `xorm:"pk"` + ActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` + NotActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` + ActivateIIndex float64 `xorm:"NOT NULL DEFAULT 0"` + HasActivityUser int `xorm:"NOT NULL DEFAULT 0"` + TotalUser int `xorm:"NOT NULL DEFAULT 0"` + TotalActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` + TotalHasActivityUser int `xorm:"NOT NULL DEFAULT 0"` + DisplayDate string `xorm:"-"` + DaysForMonth int `xorm:"NOT NULL DEFAULT 0"` + HasActivityUserJson string `xorm:"NULL"` } diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 474b96c3f..da70e984d 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -530,6 +530,19 @@ static.public.user_business_analysis_last30_day=近30天 static.public.user_business_analysis_last_month=上月 static.public.user_business_analysis_yesterday=昨天 static.public.user_business_analysis_all=所有 + +metrics.sheetname=用户趋势分析 +metrics.date=日期 +metrics.newregistuser=新增注册用户 +metrics.newregistandactiveuser=新增已激活 +metrics.hasactivateuser=新增有贡献活动 +metrics.newregistnotactiveuser=新增未激活 +metrics.averageuser=平均新增用户 +metrics.newuseractiveindex=新增用户激活率 +metrics.totalregistuser=累计注册用户 +metrics.totalregistuser=累计已激活 +metrics.totalregistuser=累计有贡献活动 + [settings] profile=个人信息 account=账号 diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 2280e8288..240613566 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -19,6 +19,53 @@ const ( PAGE_SIZE = 2000 ) +func getUserMetricsExcelHeader(ctx *context.Context) map[string]string { + excelHeader := make([]string, 0) + excelHeader = append(excelHeader, ctx.Tr("user.static.id")) + excelHeader = append(excelHeader, ctx.Tr("user.static.name")) + excelHeader = append(excelHeader, ctx.Tr("user.static.UserIndex")) + excelHeader = append(excelHeader, ctx.Tr("user.static.UserIndexPrimitive")) + excelHeader = append(excelHeader, ctx.Tr("user.static.codemergecount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.commitcount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.issuecount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.commentcount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.focusrepocount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.starrepocount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.logincount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.watchedcount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.commitcodesize")) + excelHeader = append(excelHeader, ctx.Tr("user.static.solveissuecount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.encyclopediascount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.createrepocount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.openiindex")) + excelHeader = append(excelHeader, ctx.Tr("user.static.CloudBrainTaskNum")) + excelHeader = append(excelHeader, ctx.Tr("user.static.CloudBrainRunTime")) + excelHeader = append(excelHeader, ctx.Tr("user.static.CommitDatasetNum")) + excelHeader = append(excelHeader, ctx.Tr("user.static.CommitModelCount")) + + excelHeader = append(excelHeader, ctx.Tr("user.static.FocusOtherUser")) + excelHeader = append(excelHeader, ctx.Tr("user.static.CollectDataset")) + excelHeader = append(excelHeader, ctx.Tr("user.static.CollectedDataset")) + excelHeader = append(excelHeader, ctx.Tr("user.static.RecommendDataset")) + excelHeader = append(excelHeader, ctx.Tr("user.static.CollectImage")) + excelHeader = append(excelHeader, ctx.Tr("user.static.CollectedImage")) + excelHeader = append(excelHeader, ctx.Tr("user.static.RecommendImage")) + + excelHeader = append(excelHeader, ctx.Tr("user.static.registdate")) + excelHeader = append(excelHeader, ctx.Tr("user.static.countdate")) + + excelHeaderMap := make(map[string]string, 0) + var i byte + i = 0 + for _, value := range excelHeader { + excelColumn := getColumn(i) + fmt.Sprint(1) + log.Info("excelColumn=" + excelColumn) + excelHeaderMap[excelColumn] = value + i++ + } + return excelHeaderMap +} + func getExcelHeader(ctx *context.Context) map[string]string { excelHeader := make([]string, 0) excelHeader = append(excelHeader, ctx.Tr("user.static.id")) @@ -205,11 +252,36 @@ func QueryMetrics(ctx *context.Context) { endDate := ctx.Query("endDate") startTime, _ := time.ParseInLocation("2006-01-02", startDate, time.Local) endTime, _ := time.ParseInLocation("2006-01-02", endDate, time.Local) - result, count := models.QueryMetrics(startTime.Unix(), endTime.Unix()) - mapInterface := make(map[string]interface{}) - mapInterface["data"] = result - mapInterface["count"] = count - ctx.JSON(http.StatusOK, mapInterface) + + page := ctx.QueryInt("page") + if page <= 0 { + page = 1 + } + pageSize := ctx.QueryInt("pageSize") + if pageSize <= 0 { + pageSize = setting.UI.IssuePagingNum + } + IsReturnFile := ctx.QueryBool("IsReturnFile") + + if IsReturnFile { + //writer exec file. + xlsx := excelize.NewFile() + sheetName := ctx.Tr("user.metrics.sheetname") + //index := xlsx.NewSheet(sheetName) + xlsx.DeleteSheet("Sheet1") + dataHeader := getUserMetricsExcelHeader(ctx) + for k, v := range dataHeader { + //设置单元格的值 + xlsx.SetCellValue(sheetName, k, v) + } + } else { + result, count := models.QueryMetricsPage(startTime.Unix(), endTime.Unix(), page, pageSize) + mapInterface := make(map[string]interface{}) + mapInterface["data"] = result + mapInterface["count"] = count + ctx.JSON(http.StatusOK, mapInterface) + } + } func QueryRankingList(ctx *context.Context) { From 8342c48013a1e9f5958142e9090c7c344f3a471c Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 28 Apr 2022 16:02:59 +0800 Subject: [PATCH 003/188] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 8 +++++++- models/user_business_struct.go | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 7e9e877c2..72465daa7 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -885,7 +885,11 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, log.Info("query user error. return.") } useMetrics.TotalUser = int(count) - useMetrics.ActivateIIndex = float64(useMetrics.ActivateRegistUser) / float64(useMetrics.ActivateRegistUser+useMetrics.NotActivateRegistUser) + if useMetrics.ActivateRegistUser+useMetrics.NotActivateRegistUser == 0 { + useMetrics.ActivateIndex = 0 + } else { + useMetrics.ActivateIndex = float64(useMetrics.ActivateRegistUser) / float64(useMetrics.ActivateRegistUser+useMetrics.NotActivateRegistUser) + } statictisSess.Insert(&useMetrics) //update new user activity updateNewUserAcitivity(userNewAddActivity, statictisSess) @@ -893,7 +897,9 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, } func updateNewUserAcitivity(currentUserActivity map[int64]map[int64]int64, statictisSess *xorm.Session) { + log.Info("go here len=" + fmt.Sprint(len(currentUserActivity))) for key, value := range currentUserActivity { + log.Info("key=" + fmt.Sprint(key) + " ") useMetrics := &UserMetrics{CountDate: key} has, err := statictisSess.Get(useMetrics) if err == nil && has { diff --git a/models/user_business_struct.go b/models/user_business_struct.go index 5560cb19a..8f4c94636 100644 --- a/models/user_business_struct.go +++ b/models/user_business_struct.go @@ -403,12 +403,12 @@ type UserMetrics struct { CountDate int64 `xorm:"pk"` ActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` NotActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` - ActivateIIndex float64 `xorm:"NOT NULL DEFAULT 0"` + ActivateIndex float64 `xorm:"NOT NULL DEFAULT 0"` HasActivityUser int `xorm:"NOT NULL DEFAULT 0"` TotalUser int `xorm:"NOT NULL DEFAULT 0"` TotalActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` TotalHasActivityUser int `xorm:"NOT NULL DEFAULT 0"` DisplayDate string `xorm:"-"` DaysForMonth int `xorm:"NOT NULL DEFAULT 0"` - HasActivityUserJson string `xorm:"NULL"` + HasActivityUserJson string `xorm:"text NULL"` } From 6eb83a3da7d5d53e3e4aa82c23e08ad454e36e1a Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 28 Apr 2022 16:30:40 +0800 Subject: [PATCH 004/188] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 72465daa7..b33625e06 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -901,8 +901,9 @@ func updateNewUserAcitivity(currentUserActivity map[int64]map[int64]int64, stati for key, value := range currentUserActivity { log.Info("key=" + fmt.Sprint(key) + " ") useMetrics := &UserMetrics{CountDate: key} - has, err := statictisSess.Get(useMetrics) - if err == nil && has { + _, err := statictisSess.Get(useMetrics) + log.Info("json=" + useMetrics.HasActivityUserJson + " totalUser=" + fmt.Sprint(useMetrics.TotalUser) + " len(value)=" + fmt.Sprint(len(value))) + if err == nil { userIdArrays := strings.Split(useMetrics.HasActivityUserJson, ",") for _, userIdStr := range userIdArrays { userIdInt, err := strconv.ParseInt(userIdStr, 10, 64) @@ -914,10 +915,11 @@ func updateNewUserAcitivity(currentUserActivity map[int64]map[int64]int64, stati for _, tmpValue := range value { userIdArray += fmt.Sprint(tmpValue) + "," } + useMetrics.HasActivityUser = len(value) if len(userIdArray) > 0 { useMetrics.HasActivityUserJson = userIdArray[0 : len(userIdArray)-1] - + log.Info("useMetrics.HasActivityUserJson=" + useMetrics.HasActivityUserJson) } statictisSess.Update(useMetrics) } From 3fedbeec1d5b6a688178b34a7edcfa780fd94339 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 28 Apr 2022 16:45:38 +0800 Subject: [PATCH 005/188] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index b33625e06..93bc640c0 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -901,9 +901,9 @@ func updateNewUserAcitivity(currentUserActivity map[int64]map[int64]int64, stati for key, value := range currentUserActivity { log.Info("key=" + fmt.Sprint(key) + " ") useMetrics := &UserMetrics{CountDate: key} - _, err := statictisSess.Get(useMetrics) + has, err := statictisSess.Get(useMetrics) log.Info("json=" + useMetrics.HasActivityUserJson + " totalUser=" + fmt.Sprint(useMetrics.TotalUser) + " len(value)=" + fmt.Sprint(len(value))) - if err == nil { + if err == nil && has { userIdArrays := strings.Split(useMetrics.HasActivityUserJson, ",") for _, userIdStr := range userIdArrays { userIdInt, err := strconv.ParseInt(userIdStr, 10, 64) @@ -921,7 +921,9 @@ func updateNewUserAcitivity(currentUserActivity map[int64]map[int64]int64, stati useMetrics.HasActivityUserJson = userIdArray[0 : len(userIdArray)-1] log.Info("useMetrics.HasActivityUserJson=" + useMetrics.HasActivityUserJson) } - statictisSess.Update(useMetrics) + updateSql := "update public.user_metrics set has_activity_user_json=" + useMetrics.HasActivityUserJson + " where count_date=" + fmt.Sprint(key) + statictisSess.Exec(updateSql) + //statictisSess.Update(useMetrics) } } } From b6def70bb4e78a38fc3e309ca81459a54d0e4bae Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 28 Apr 2022 17:01:38 +0800 Subject: [PATCH 006/188] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 93bc640c0..311c3ae43 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -897,12 +897,9 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, } func updateNewUserAcitivity(currentUserActivity map[int64]map[int64]int64, statictisSess *xorm.Session) { - log.Info("go here len=" + fmt.Sprint(len(currentUserActivity))) for key, value := range currentUserActivity { - log.Info("key=" + fmt.Sprint(key) + " ") useMetrics := &UserMetrics{CountDate: key} has, err := statictisSess.Get(useMetrics) - log.Info("json=" + useMetrics.HasActivityUserJson + " totalUser=" + fmt.Sprint(useMetrics.TotalUser) + " len(value)=" + fmt.Sprint(len(value))) if err == nil && has { userIdArrays := strings.Split(useMetrics.HasActivityUserJson, ",") for _, userIdStr := range userIdArrays { @@ -915,15 +912,12 @@ func updateNewUserAcitivity(currentUserActivity map[int64]map[int64]int64, stati for _, tmpValue := range value { userIdArray += fmt.Sprint(tmpValue) + "," } - useMetrics.HasActivityUser = len(value) if len(userIdArray) > 0 { useMetrics.HasActivityUserJson = userIdArray[0 : len(userIdArray)-1] - log.Info("useMetrics.HasActivityUserJson=" + useMetrics.HasActivityUserJson) } - updateSql := "update public.user_metrics set has_activity_user_json=" + useMetrics.HasActivityUserJson + " where count_date=" + fmt.Sprint(key) + updateSql := "update public.user_metrics set has_activity_user_json=" + useMetrics.HasActivityUserJson + ",has_activity_user=" + fmt.Sprint(useMetrics.HasActivityUser) + " where count_date=" + fmt.Sprint(key) statictisSess.Exec(updateSql) - //statictisSess.Update(useMetrics) } } } From fb5513fdfdbf93ccf1751fc5456d94e41d46f3f1 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 29 Apr 2022 09:56:25 +0800 Subject: [PATCH 007/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 3 ++- models/user_business_struct.go | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 311c3ae43..d5ac13fbb 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -876,6 +876,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, useMetrics.ActivateRegistUser = getMapKeyStringValue("ActivateRegistUser", userMetrics) useMetrics.HasActivityUser = getMapKeyStringValue("HasActivityUser", userMetrics) + useMetrics.RegistActivityUser = 0 useMetrics.NotActivateRegistUser = getMapKeyStringValue("NotActivateRegistUser", userMetrics) useMetrics.TotalActivateRegistUser = getMapKeyStringValue("TotalActivateRegistUser", userMetrics) useMetrics.TotalHasActivityUser = getMapKeyStringValue("TotalHasActivityUser", userMetrics) @@ -916,7 +917,7 @@ func updateNewUserAcitivity(currentUserActivity map[int64]map[int64]int64, stati if len(userIdArray) > 0 { useMetrics.HasActivityUserJson = userIdArray[0 : len(userIdArray)-1] } - updateSql := "update public.user_metrics set has_activity_user_json=" + useMetrics.HasActivityUserJson + ",has_activity_user=" + fmt.Sprint(useMetrics.HasActivityUser) + " where count_date=" + fmt.Sprint(key) + updateSql := "update public.user_metrics set has_activity_user_json=" + useMetrics.HasActivityUserJson + ",regist_activity_user=" + fmt.Sprint(useMetrics.HasActivityUser) + " where count_date=" + fmt.Sprint(key) statictisSess.Exec(updateSql) } } diff --git a/models/user_business_struct.go b/models/user_business_struct.go index 8f4c94636..ad4ff0bdb 100644 --- a/models/user_business_struct.go +++ b/models/user_business_struct.go @@ -404,6 +404,7 @@ type UserMetrics struct { ActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` NotActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` ActivateIndex float64 `xorm:"NOT NULL DEFAULT 0"` + RegistActivityUser int `xorm:"NOT NULL DEFAULT 0"` HasActivityUser int `xorm:"NOT NULL DEFAULT 0"` TotalUser int `xorm:"NOT NULL DEFAULT 0"` TotalActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` From 32e8f9846ae8e68d7e660ead655c55a10f47f049 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Fri, 29 Apr 2022 10:42:10 +0800 Subject: [PATCH 008/188] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E9=95=9C=E5=83=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/cloudbrain_image.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/cloudbrain_image.go b/models/cloudbrain_image.go index eb21e0d87..0665cab43 100644 --- a/models/cloudbrain_image.go +++ b/models/cloudbrain_image.go @@ -45,7 +45,7 @@ type ImageStar struct { } type ImageTopic struct { - ID int64 + ID int64 `xorm:"pk autoincr"` Name string `xorm:"UNIQUE VARCHAR(105)"` ImageCount int CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` From 4c4cc0213b649cdff401c40640b4ab98d0823103 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Fri, 29 Apr 2022 10:55:37 +0800 Subject: [PATCH 009/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/cloudbrain_image.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/models/cloudbrain_image.go b/models/cloudbrain_image.go index 0665cab43..487fdfbd4 100644 --- a/models/cloudbrain_image.go +++ b/models/cloudbrain_image.go @@ -468,8 +468,10 @@ func (images ImageList) loadAttributes(e Engine, uid int64) error { } for i := range images { - images[i].UserName = users[images[i].UID].Name - images[i].RelAvatarLink = users[images[i].UID].RelAvatarLink() + if users[images[i].UID] != nil { + images[i].UserName = users[images[i].UID].Name + images[i].RelAvatarLink = users[images[i].UID].RelAvatarLink() + } if uid == -1 { images[i].IsStar = false } else { From eeac639db154aa4f14b31d2bc606b635cf7c60fd Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Fri, 29 Apr 2022 10:59:06 +0800 Subject: [PATCH 010/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/cloudbrain_image.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/models/cloudbrain_image.go b/models/cloudbrain_image.go index 487fdfbd4..f72c6a27c 100644 --- a/models/cloudbrain_image.go +++ b/models/cloudbrain_image.go @@ -471,6 +471,9 @@ func (images ImageList) loadAttributes(e Engine, uid int64) error { if users[images[i].UID] != nil { images[i].UserName = users[images[i].UID].Name images[i].RelAvatarLink = users[images[i].UID].RelAvatarLink() + } else { + images[i].UserName = "" + images[i].RelAvatarLink = "" } if uid == -1 { images[i].IsStar = false From aec9268bd16550b6f4d882d2da44c2909e1d791f Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Fri, 29 Apr 2022 16:45:33 +0800 Subject: [PATCH 011/188] fix issue --- web_src/js/components/images/Images.vue | 10 ++++++++++ web_src/js/features/clipboard.js | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/web_src/js/components/images/Images.vue b/web_src/js/components/images/Images.vue index 4c0eb7839..d524f6e15 100644 --- a/web_src/js/components/images/Images.vue +++ b/web_src/js/components/images/Images.vue @@ -638,6 +638,16 @@ export default { cInput.select() document.execCommand('Copy') cInput.remove() + $('body') + .toast({ + message: '复制成功!', + showProgress: 'bottom', + showIcon:'check circle', + class: 'success', + position: 'top right', + compact:false, + }) + ; }, searchName(){ if(this.activeName=='first'){ diff --git a/web_src/js/features/clipboard.js b/web_src/js/features/clipboard.js index a3b6b26eb..8965a798c 100644 --- a/web_src/js/features/clipboard.js +++ b/web_src/js/features/clipboard.js @@ -12,6 +12,15 @@ export default async function initClipboard() { e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-success')); $(`#${e.trigger.getAttribute('id')}`).popup('show'); e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-original')); + $('body') + .toast({ + message: '复制成功!', + showProgress: 'bottom', + showIcon:'check circle', + class: 'success', + position: 'top right', + compact:false, + }) }); clipboard.on('error', (e) => { From d3252d42188d9d8f016b05c0bd2dc140ebff7d78 Mon Sep 17 00:00:00 2001 From: wangjr Date: Fri, 29 Apr 2022 17:21:12 +0800 Subject: [PATCH 012/188] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E5=AD=97?= =?UTF-8?q?=E7=9C=8B=E6=9D=BF=E6=96=B0=E5=A2=9E=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/js/components/DataAnalysis.vue | 151 ++- web_src/js/components/DataAnalysis1.vue | 158 +++ web_src/js/components/Overview.vue | 5 + web_src/js/components/ProAnalysis.vue | 2 +- web_src/js/components/ProAnalysis1.vue | 1336 +++++++++++++++++++++++ web_src/js/components/ProTend.vue | 1000 +++++++++++++++++ web_src/js/components/UserAnalysis.vue | 2 +- web_src/js/components/UserAnalysis1.vue | 520 +++++++++ web_src/js/index.js | 4 +- web_src/js/router/index.js | 45 + web_src/js/router/main_.js | 17 + 11 files changed, 3187 insertions(+), 53 deletions(-) create mode 100644 web_src/js/components/DataAnalysis1.vue create mode 100644 web_src/js/components/Overview.vue create mode 100644 web_src/js/components/ProAnalysis1.vue create mode 100644 web_src/js/components/ProTend.vue create mode 100644 web_src/js/components/UserAnalysis1.vue create mode 100644 web_src/js/router/index.js create mode 100644 web_src/js/router/main_.js diff --git a/web_src/js/components/DataAnalysis.vue b/web_src/js/components/DataAnalysis.vue index 186a216c2..68af96239 100755 --- a/web_src/js/components/DataAnalysis.vue +++ b/web_src/js/components/DataAnalysis.vue @@ -1,4 +1,4 @@ - - + diff --git a/web_src/js/components/images/selectImages.vue b/web_src/js/components/images/selectImages.vue index 3359b2962..cc706fd86 100644 --- a/web_src/js/components/images/selectImages.vue +++ b/web_src/js/components/images/selectImages.vue @@ -37,7 +37,7 @@ - {{publicData.description}} @@ -73,7 +73,7 @@ - {{customData.description}} @@ -125,7 +125,7 @@ - {{starData.description}} From bb642080ca3653cc4d74e2a9fc2cec9f96b111e6 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 16 May 2022 15:38:24 +0800 Subject: [PATCH 128/188] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 4de0c6d1a..453838351 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -233,11 +233,7 @@ func QueryMetricsPage(start int64, end int64, page int, pageSize int) ([]*UserMe statictisSess := xStatistic.NewSession() defer statictisSess.Close() cond := "count_date >" + fmt.Sprint(start) + " and count_date<" + fmt.Sprint(end) - allCount, err := statictisSess.Where(cond).Count(new(UserMetrics)) - if err != nil { - log.Info("query error." + err.Error()) - return nil, 0 - } + userMetricsList := make([]*UserMetrics, 0) //.Limit(pageSize, page*pageSize) if err := statictisSess.Table(new(UserMetrics)).Where(cond).OrderBy("count_date desc"). @@ -245,7 +241,7 @@ func QueryMetricsPage(start int64, end int64, page int, pageSize int) ([]*UserMe return nil, 0 } postDeal(userMetricsList) - return userMetricsList, allCount + return userMetricsList, int64(len(userMetricsList)) } func QueryMetrics(start int64, end int64) ([]*UserMetrics, int) { @@ -260,7 +256,21 @@ func QueryMetrics(start int64, end int64) ([]*UserMetrics, int) { return userMetricsList, len(userMetricsList) } +func duplicateRemoval(userMetricsList []*UserMetrics) []*UserMetrics { + userMetricsResult := make([]*UserMetrics, 0) + for i := 0; i < len(userMetricsList); i++ { + if i > 0 { + if userMetricsList[i].DataDate == userMetricsList[i-1].DataDate { + continue + } + } + userMetricsResult = append(userMetricsResult, userMetricsList[i]) + } + return userMetricsResult +} + func postDeal(userMetricsList []*UserMetrics) { + userMetricsList = duplicateRemoval(userMetricsList) for _, userMetrics := range userMetricsList { userMetrics.DisplayDate = userMetrics.DataDate userMetrics.TotalRegistUser = userMetrics.ActivateRegistUser + userMetrics.NotActivateRegistUser @@ -276,6 +286,7 @@ func QueryMetricsForAll() []*UserMetrics { Find(&userMetricsList); err != nil { return nil } + userMetricsList = duplicateRemoval(userMetricsList) return makeResultForMonth(userMetricsList, len(userMetricsList)) } From 03dff4252eeecab741ed759a1c1e273568864553 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 16 May 2022 15:48:46 +0800 Subject: [PATCH 129/188] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 453838351..cd270510e 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -240,8 +240,8 @@ func QueryMetricsPage(start int64, end int64, page int, pageSize int) ([]*UserMe Find(&userMetricsList); err != nil { return nil, 0 } - postDeal(userMetricsList) - return userMetricsList, int64(len(userMetricsList)) + postUserMetricsList := postDeal(userMetricsList) + return postUserMetricsList, int64(len(postUserMetricsList)) } func QueryMetrics(start int64, end int64) ([]*UserMetrics, int) { @@ -252,8 +252,8 @@ func QueryMetrics(start int64, end int64) ([]*UserMetrics, int) { Find(&userMetricsList); err != nil { return nil, 0 } - postDeal(userMetricsList) - return userMetricsList, len(userMetricsList) + postUserMetricsList := postDeal(userMetricsList) + return postUserMetricsList, int(len(postUserMetricsList)) } func duplicateRemoval(userMetricsList []*UserMetrics) []*UserMetrics { @@ -269,13 +269,14 @@ func duplicateRemoval(userMetricsList []*UserMetrics) []*UserMetrics { return userMetricsResult } -func postDeal(userMetricsList []*UserMetrics) { - userMetricsList = duplicateRemoval(userMetricsList) - for _, userMetrics := range userMetricsList { +func postDeal(userMetricsList []*UserMetrics) []*UserMetrics { + duplicateRemovalUserMetricsList := duplicateRemoval(userMetricsList) + for _, userMetrics := range duplicateRemovalUserMetricsList { userMetrics.DisplayDate = userMetrics.DataDate userMetrics.TotalRegistUser = userMetrics.ActivateRegistUser + userMetrics.NotActivateRegistUser userMetrics.TotalNotActivateRegistUser = userMetrics.TotalUser - userMetrics.TotalActivateRegistUser } + return duplicateRemovalUserMetricsList } func QueryMetricsForAll() []*UserMetrics { @@ -286,8 +287,8 @@ func QueryMetricsForAll() []*UserMetrics { Find(&userMetricsList); err != nil { return nil } - userMetricsList = duplicateRemoval(userMetricsList) - return makeResultForMonth(userMetricsList, len(userMetricsList)) + duplicateRemovalUserMetricsList := duplicateRemoval(userMetricsList) + return makeResultForMonth(duplicateRemovalUserMetricsList, len(duplicateRemovalUserMetricsList)) } func QueryMetricsForYear() []*UserMetrics { From b1b05ae44d3442105d6c33d8335c4048db319181 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 16 May 2022 16:20:45 +0800 Subject: [PATCH 130/188] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- modules/cloudbrain/cloudbrain.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/cloudbrain/cloudbrain.go b/modules/cloudbrain/cloudbrain.go index 8888361e8..a71389741 100755 --- a/modules/cloudbrain/cloudbrain.go +++ b/modules/cloudbrain/cloudbrain.go @@ -18,7 +18,6 @@ import ( const ( Command = `pip3 install jupyterlab==2.2.5 -i https://pypi.tuna.tsinghua.edu.cn/simple;service ssh stop;jupyter lab --no-browser --ip=0.0.0.0 --allow-root --notebook-dir="/code" --port=80 --LabApp.token="" --LabApp.allow_origin="self https://cloudbrain.pcl.ac.cn"` - //Command = `service ssh stop;jupyter lab --no-browser --ip=0.0.0.0 --allow-root --notebook-dir="/code" --port=80 --LabApp.token="" --LabApp.allow_origin="self https://cloudbrain.pcl.ac.cn"` //CommandBenchmark = `echo "start benchmark";python /code/test.py;echo "end benchmark"` CommandBenchmark = `echo "start benchmark";cd /benchmark && bash run_bk.sh;echo "end benchmark"` CodeMountPath = "/code" @@ -30,6 +29,8 @@ const ( Snn4imagenetMountPath = "/snn4imagenet" BrainScoreMountPath = "/brainscore" TaskInfoName = "/taskInfo" + Snn4imagenetCommand = `/opt/conda/bin/python /snn4imagenet/testSNN_script.py --modelname '%s' --modelpath '/dataset' --modeldescription '%s'` + BrainScoreCommand = `bash /brainscore/brainscore_test_par4shSrcipt.sh -b '%s' -n '%s' -p '/dataset' -d '%s'` SubTaskName = "task1" @@ -348,7 +349,7 @@ func GenerateTask(ctx *context.Context, displayJobName, jobName, image, command, } stringId := strconv.FormatInt(task.ID, 10) - if string(models.JobTypeBenchmark) == jobType { + if IsBenchmarkJob(jobType) { notification.NotifyOtherTask(ctx.User, ctx.Repo.Repository, stringId, displayJobName, models.ActionCreateBenchMarkTask) } else if string(models.JobTypeTrain) == jobType { notification.NotifyOtherTask(ctx.User, ctx.Repo.Repository, jobID, displayJobName, models.ActionCreateGPUTrainTask) @@ -359,6 +360,10 @@ func GenerateTask(ctx *context.Context, displayJobName, jobName, image, command, return nil } +func IsBenchmarkJob(jobType string) bool { + return string(models.JobTypeBenchmark) == jobType || string(models.JobTypeBrainScore) == jobType || string(models.JobTypeSnn4imagenet) == jobType +} + func RestartTask(ctx *context.Context, task *models.Cloudbrain, newID *string) error { dataActualPath := setting.Attachment.Minio.RealPath + setting.Attachment.Minio.Bucket + "/" + From 67f7cac54553bb868786c54cdac30880bac04148 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 16 May 2022 16:51:07 +0800 Subject: [PATCH 131/188] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=97=B6=E9=97=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 2 +- routers/private/internal.go | 5 +++-- routers/private/tool.go | 5 +++++ routers/repo/user_data_analysis.go | 10 ++++++++++ web_src/js/components/UserTrend.vue | 6 +++--- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index cd270510e..f53039ebd 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -891,9 +891,9 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, //insert userMetrics table var useMetrics UserMetrics useMetrics.CountDate = CountDate.Unix() - useMetrics.DataDate = DataDate statictisSess.Delete(&useMetrics) + useMetrics.DataDate = DataDate useMetrics.ActivateRegistUser = getMapKeyStringValue("ActivateRegistUser", userMetrics) useMetrics.HasActivityUser = getMapKeyStringValue("HasActivityUser", userMetrics) useMetrics.RegistActivityUser = 0 diff --git a/routers/private/internal.go b/routers/private/internal.go index a0c2843be..4731463b1 100755 --- a/routers/private/internal.go +++ b/routers/private/internal.go @@ -6,9 +6,10 @@ package private import ( - "code.gitea.io/gitea/routers/repo" "strings" + "code.gitea.io/gitea/routers/repo" + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/private" "code.gitea.io/gitea/modules/setting" @@ -46,7 +47,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/manager/flush-queues", bind(private.FlushOptions{}), FlushQueues) m.Post("/tool/update_all_repo_commit_cnt", UpdateAllRepoCommitCnt) m.Post("/tool/repo_stat/:date", RepoStatisticManually) - + m.Post("/tool/user_stat/:date", UserStatisticManually) m.Get("/tool/org_stat", OrgStatisticManually) m.Post("/tool/update_repo_visit/:date", UpdateRepoVisit) m.Post("/task/history_handle/duration", repo.HandleTaskWithNoDuration) diff --git a/routers/private/tool.go b/routers/private/tool.go index 122a41afe..f8b1a2c3f 100755 --- a/routers/private/tool.go +++ b/routers/private/tool.go @@ -45,6 +45,11 @@ func RepoStatisticManually(ctx *macaron.Context) { repo.TimingCountDataByDate(date) } +func UserStatisticManually(ctx *macaron.Context) { + date := ctx.Params("date") + repo.TimingCountDataByDate(date) +} + func OrgStatisticManually() { models.UpdateOrgStatistics() } diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 2823f9c87..cd17e5202 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -247,6 +247,7 @@ func queryUserDataPage(ctx *context.Context, tableName string, queryObj interfac mapInterface := make(map[string]interface{}) mapInterface["data"] = re mapInterface["count"] = count + ctx.JSON(http.StatusOK, mapInterface) } } @@ -303,6 +304,15 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e mapInterface := make(map[string]interface{}) mapInterface["data"] = result mapInterface["count"] = count + if tableName == "public.user_business_analysis_yesterday" { + mapInterface["datarecordbegintime"] = setting.RadarMap.RecordBeginTime + if len(result) > 0 { + dateTime := time.Unix(result[0].CountDate, 0) + mapInterface["lastUpdatedTime"] = dateTime.Format("2006-01-02 15:04:05") + } else { + mapInterface["lastUpdatedTime"] = "" + } + } ctx.JSON(http.StatusOK, mapInterface) } diff --git a/web_src/js/components/UserTrend.vue b/web_src/js/components/UserTrend.vue index 489d65cbb..a8a573247 100644 --- a/web_src/js/components/UserTrend.vue +++ b/web_src/js/components/UserTrend.vue @@ -257,11 +257,11 @@ return days; }, getUpdateTime(){ - this.$axios.get('../../api/v1/projectboard/project',{ + this.$axios.get('../../api/v1//query_metrics_yesterday',{ params:this.params_pro }).then((res)=>{ - this.recordBeginTime=res.data.recordBeginTime - this.lastUpdatedTime=res.data.lastUpdatedTime + this.recordBeginTime=res.datarecordbegintime + this.lastUpdatedTime=res.lastUpdatedTime }) }, getUserList(type_val,index){ From 2e8368e6414a1aacdadb1cf52ec8e0465bec47c3 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 16 May 2022 16:59:48 +0800 Subject: [PATCH 132/188] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=97=B6=E9=97=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- web_src/js/components/UserTrend.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/components/UserTrend.vue b/web_src/js/components/UserTrend.vue index a8a573247..22bbf2798 100644 --- a/web_src/js/components/UserTrend.vue +++ b/web_src/js/components/UserTrend.vue @@ -257,7 +257,7 @@ return days; }, getUpdateTime(){ - this.$axios.get('../../api/v1//query_metrics_yesterday',{ + this.$axios.get('../../api/v1/query_metrics_yesterday',{ params:this.params_pro }).then((res)=>{ this.recordBeginTime=res.datarecordbegintime From 397f9c12691c743381f23583e0f6fbb2cf84ab2a Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 16 May 2022 17:30:07 +0800 Subject: [PATCH 133/188] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=97=B6=E9=97=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- web_src/js/components/UserTrend.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_src/js/components/UserTrend.vue b/web_src/js/components/UserTrend.vue index 22bbf2798..fcc4ede4b 100644 --- a/web_src/js/components/UserTrend.vue +++ b/web_src/js/components/UserTrend.vue @@ -260,8 +260,8 @@ this.$axios.get('../../api/v1/query_metrics_yesterday',{ params:this.params_pro }).then((res)=>{ - this.recordBeginTime=res.datarecordbegintime - this.lastUpdatedTime=res.lastUpdatedTime + this.recordBeginTime=res.data.datarecordbegintime + this.lastUpdatedTime=res.data.lastUpdatedTime }) }, getUserList(type_val,index){ From e82b8b70c856f33f82015a78c2b369ef5c38160d Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 16 May 2022 17:32:23 +0800 Subject: [PATCH 134/188] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=97=B6=E9=97=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index cd17e5202..9707f8df2 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -305,7 +305,7 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e mapInterface["data"] = result mapInterface["count"] = count if tableName == "public.user_business_analysis_yesterday" { - mapInterface["datarecordbegintime"] = setting.RadarMap.RecordBeginTime + mapInterface["datarecordbegintime"] = setting.RadarMap.GrowthBeginTime if len(result) > 0 { dateTime := time.Unix(result[0].CountDate, 0) mapInterface["lastUpdatedTime"] = dateTime.Format("2006-01-02 15:04:05") From 15942c8b373fd8387d82c3e479fe0c62f096c0b1 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 09:48:00 +0800 Subject: [PATCH 135/188] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=97=B6=E9=97=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index f53039ebd..6b1b66c84 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -325,7 +325,7 @@ func makeResultForMonth(allUserInfo []*UserMetrics, count int) []*UserMetrics { value.ActivateRegistUser += userMetrics.ActivateRegistUser value.NotActivateRegistUser += userMetrics.NotActivateRegistUser value.HasActivityUser += userMetrics.HasActivityUser - value.TotalRegistUser += userMetrics.TotalRegistUser + value.TotalRegistUser += userMetrics.ActivateRegistUser + userMetrics.NotActivateRegistUser value.DaysForMonth += 1 } } From 616e914be44ff49cfbd8e5bc2bbf82b1e4ceff8b Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 17 May 2022 10:20:36 +0800 Subject: [PATCH 136/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/cloudbrain/cloudbrain.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/cloudbrain/cloudbrain.go b/modules/cloudbrain/cloudbrain.go index 3dee3a3fa..214897789 100755 --- a/modules/cloudbrain/cloudbrain.go +++ b/modules/cloudbrain/cloudbrain.go @@ -1,10 +1,12 @@ package cloudbrain import ( - "code.gitea.io/gitea/modules/timeutil" "encoding/json" "errors" "strconv" + "strings" + + "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/storage" @@ -188,7 +190,7 @@ func AdminOrImageCreaterRight(ctx *context.Context) { func GenerateTask(ctx *context.Context, displayJobName, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, brainScorePath, jobType, gpuQueue, description, branchName, bootFile, params string, benchmarkTypeID, benchmarkChildTypeID, resourceSpecId int) error { - + image = strings.TrimSpace(image) dataActualPath := setting.Attachment.Minio.RealPath + setting.Attachment.Minio.Bucket + "/" + setting.Attachment.Minio.BasePath + From 310b8edf3545a273fc603fdcdfb4c0bca29136c8 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 17 May 2022 11:03:35 +0800 Subject: [PATCH 137/188] =?UTF-8?q?=E5=8D=95=E8=AF=8D=E6=8B=BC=E5=86=99?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/setting/setting.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index f8b7965f2..fbff1ff7d 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -1416,8 +1416,8 @@ func SetRadarMapConfig() { RadarMap.GrowthContributors = sec.Key("growth_contributors").MustFloat64(0.2) RadarMap.GrowthCommit = sec.Key("growth_commit").MustFloat64(0.2) RadarMap.GrowthComments = sec.Key("growth_comments").MustFloat64(0.2) - RadarMap.RecordBeginTime = sec.Key("record_beigin_time").MustString("2021-11-05") - RadarMap.GrowthBeginTime = sec.Key("growth_beigin_time").MustString("2022-05-20") + RadarMap.RecordBeginTime = sec.Key("record_begin_time").MustString("2021-11-05") + RadarMap.GrowthBeginTime = sec.Key("growth_begin_time").MustString("2022-05-20") RadarMap.IgnoreMirrorRepo = sec.Key("ignore_mirror_repo").MustBool(true) } From 5442f2c1da4dcfac6ef4ed70d69c4c7f94c78f18 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 11:09:26 +0800 Subject: [PATCH 138/188] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 9707f8df2..4706414e2 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -47,9 +47,7 @@ func writeUserMetricsExcel(row int, xlsx *excelize.File, sheetName string, userM rows := fmt.Sprint(row) var tmp byte tmp = 0 - dateTime := time.Unix(userMetrics.CountDate, 0) - //dateTime.Format("2006-01-02 15:04:05") - xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, dateTime.Format("2006-01-02 15:04:05")) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userMetrics.DisplayDate) tmp = tmp + 1 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userMetrics.ActivateRegistUser+userMetrics.NotActivateRegistUser) tmp = tmp + 1 From ce95cc502311f7b80cefbe14e736a518918ff23a Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 11:22:48 +0800 Subject: [PATCH 139/188] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 4706414e2..03806cc8d 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -329,14 +329,25 @@ func QueryRankingList(ctx *context.Context) { } func QueryUserMetricsCurrentMonth(ctx *context.Context) { + currentTimeNow := time.Now() pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), 1, 0, 0, 0, 0, currentTimeNow.Location()) + pageStartTime = getStartTime(pageStartTime) queryMetrics(ctx, "public.user_business_analysis_current_month", pageStartTime, pageEndTime) } func QueryUserStaticCurrentMonth(ctx *context.Context) { queryUserDataPage(ctx, "public.user_business_analysis_current_month", new(models.UserBusinessAnalysisCurrentMonth)) } + +func getStartTime(pageStartTime time.Time) time.Time { + t, _ := time.Parse("2006-01-02", setting.RadarMap.GrowthBeginTime) + if pageStartTime.Before(t) { + pageStartTime = t + } + return pageStartTime +} + func QueryUserMetricsCurrentWeek(ctx *context.Context) { currentTimeNow := time.Now() offset := int(time.Monday - currentTimeNow.Weekday()) @@ -344,6 +355,7 @@ func QueryUserMetricsCurrentWeek(ctx *context.Context) { offset = -6 } pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset) + pageStartTime = getStartTime(pageStartTime) pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) queryMetrics(ctx, "public.user_business_analysis_current_week", pageStartTime, pageEndTime) } @@ -353,6 +365,7 @@ func QueryUserStaticCurrentWeek(ctx *context.Context) { func QueryUserMetricsCurrentYear(ctx *context.Context) { currentTimeNow := time.Now() pageStartTime := time.Date(currentTimeNow.Year(), 1, 1, 0, 0, 0, 0, currentTimeNow.Location()) + pageStartTime = getStartTime(pageStartTime) pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) queryMetrics(ctx, "public.user_business_analysis_current_year", pageStartTime, pageEndTime) } @@ -362,6 +375,7 @@ func QueryUserStaticCurrentYear(ctx *context.Context) { func QueryUserMetricsLast30Day(ctx *context.Context) { currentTimeNow := time.Now() pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, -30) + pageStartTime = getStartTime(pageStartTime) pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) queryMetrics(ctx, "public.user_business_analysis_last30_day", pageStartTime, pageEndTime) } @@ -372,6 +386,7 @@ func QueryUserMetricsLastMonth(ctx *context.Context) { currentTimeNow := time.Now() thisMonth := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), 1, 0, 0, 0, 0, currentTimeNow.Location()) pageStartTime := thisMonth.AddDate(0, -1, 0) + pageStartTime = getStartTime(pageStartTime) pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), 1, 23, 59, 59, 0, currentTimeNow.Location()).AddDate(0, 0, -1) queryMetrics(ctx, "public.user_business_analysis_last_month", pageStartTime, pageEndTime) } @@ -381,6 +396,7 @@ func QueryUserStaticLastMonth(ctx *context.Context) { func QueryUserMetricsYesterday(ctx *context.Context) { currentTimeNow := time.Now() pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local) + pageStartTime = getStartTime(pageStartTime) pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) queryMetrics(ctx, "public.user_business_analysis_yesterday", pageStartTime, pageEndTime) } @@ -390,6 +406,7 @@ func QueryUserStaticYesterday(ctx *context.Context) { func QueryUserMetricsAll(ctx *context.Context) { currentTimeNow := time.Now() pageStartTime := time.Date(2022, 4, 5, 0, 0, 0, 0, currentTimeNow.Location()) + pageStartTime = getStartTime(pageStartTime) pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) queryMetrics(ctx, "public.user_business_analysis_all", pageStartTime, pageEndTime) } From 17bb072640ede9393c51877c14adb0d06951f200 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 11:35:05 +0800 Subject: [PATCH 140/188] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=88=86=E6=9E=90=E7=BB=9F=E8=AE=A1=E6=9C=AA=E6=BF=80=E6=B4=BB?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 20 ++++++++++---------- routers/repo/user_data_analysis.go | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 6b1b66c84..6e949dd93 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -279,11 +279,11 @@ func postDeal(userMetricsList []*UserMetrics) []*UserMetrics { return duplicateRemovalUserMetricsList } -func QueryMetricsForAll() []*UserMetrics { +func QueryMetricsForAll(start int64, end int64) []*UserMetrics { statictisSess := xStatistic.NewSession() defer statictisSess.Close() userMetricsList := make([]*UserMetrics, 0) - if err := statictisSess.Table(new(UserMetrics)).OrderBy("count_date desc"). + if err := statictisSess.Table(new(UserMetrics)).Where("count_date >" + fmt.Sprint(start) + " and count_date<" + fmt.Sprint(end)).OrderBy("count_date desc"). Find(&userMetricsList); err != nil { return nil } @@ -291,11 +291,9 @@ func QueryMetricsForAll() []*UserMetrics { return makeResultForMonth(duplicateRemovalUserMetricsList, len(duplicateRemovalUserMetricsList)) } -func QueryMetricsForYear() []*UserMetrics { - currentTimeNow := time.Now() - currentYearEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) - currentYearStartTime := time.Date(currentTimeNow.Year(), 1, 1, 0, 0, 0, 0, currentTimeNow.Location()) - allUserInfo, count := QueryMetrics(currentYearStartTime.Unix(), currentYearEndTime.Unix()) +func QueryMetricsForYear(start int64, end int64) []*UserMetrics { + + allUserInfo, count := QueryMetrics(start, end) return makeResultForMonth(allUserInfo, count) } @@ -792,7 +790,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, statictisSess := xStatistic.NewSession() defer statictisSess.Close() - cond := "type != 1 and is_active=true" + cond := "type != 1" count, err := sess.Where(cond).Count(new(User)) if err != nil { log.Info("query user error. return.") @@ -814,8 +812,6 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, log.Info("i=" + fmt.Sprint(i) + " userName=" + userRecord.Name) dateRecord.CountDate = CountDate.Unix() - statictisSess.Delete(&dateRecord) - dateRecord.Email = userRecord.Email dateRecord.RegistDate = userRecord.CreatedUnix dateRecord.Name = userRecord.Name @@ -873,6 +869,10 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, if getUserActivate(dateRecord) > 0 { addUserToMap(userNewAddActivity, userRecord.CreatedUnix, dateRecord.ID) } + if userRecord.IsActive { + continue + } + statictisSess.Delete(&dateRecord) _, err = statictisSess.Insert(&dateRecord) if err != nil { log.Info("insert daterecord failed." + err.Error()) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 03806cc8d..e81601331 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -265,10 +265,10 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e var count int64 result := make([]*models.UserMetrics, 0) if tableName == "public.user_business_analysis_current_year" { - result = models.QueryMetricsForYear() + result = models.QueryMetricsForYear(startTime.Unix(), endTime.Unix()) count = int64(len(result)) } else if tableName == "public.user_business_analysis_all" { - result = models.QueryMetricsForAll() + result = models.QueryMetricsForAll(startTime.Unix(), endTime.Unix()) count = int64(len(result)) } else { result, count = models.QueryMetricsPage(startTime.Unix(), endTime.Unix(), page, pageSize) From 32e32c372efb1b8a63c6bfd1365e97814af45b7c Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 14:20:08 +0800 Subject: [PATCH 141/188] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=88=86=E6=9E=90=E7=BB=9F=E8=AE=A1=E6=9C=AA=E6=BF=80=E6=B4=BB?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 3 ++- web_src/js/components/UserTrend.vue | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index e81601331..ea14f99df 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -59,7 +59,8 @@ func writeUserMetricsExcel(row int, xlsx *excelize.File, sheetName string, userM tmp = tmp + 1 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, "") tmp = tmp + 1 - xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, fmt.Sprintf("%.2f", userMetrics.ActivateIndex)) + t := userMetrics.ActivateIndex * 100 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, fmt.Sprintf("%.2f", t)+"%") tmp = tmp + 1 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userMetrics.TotalUser) tmp = tmp + 1 diff --git a/web_src/js/components/UserTrend.vue b/web_src/js/components/UserTrend.vue index fcc4ede4b..6ad8114bc 100644 --- a/web_src/js/components/UserTrend.vue +++ b/web_src/js/components/UserTrend.vue @@ -127,6 +127,9 @@ prop="ActivateIndex" label="新增用户激活率" align="center"> + Date: Tue, 17 May 2022 14:27:05 +0800 Subject: [PATCH 142/188] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=88=86=E6=9E=90=E7=BB=9F=E8=AE=A1=E6=9C=AA=E6=BF=80=E6=B4=BB?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 8 +++++++- web_src/js/components/UserTrend.vue | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index ea14f99df..6b6bcf233 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -60,7 +60,13 @@ func writeUserMetricsExcel(row int, xlsx *excelize.File, sheetName string, userM xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, "") tmp = tmp + 1 t := userMetrics.ActivateIndex * 100 - xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, fmt.Sprintf("%.2f", t)+"%") + value := "-" + if t < 100 { + value = fmt.Sprintf("%.2f", t) + "%" + } else { + value = "100%" + } + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, value) tmp = tmp + 1 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userMetrics.TotalUser) tmp = tmp + 1 diff --git a/web_src/js/components/UserTrend.vue b/web_src/js/components/UserTrend.vue index 6ad8114bc..6b5be7940 100644 --- a/web_src/js/components/UserTrend.vue +++ b/web_src/js/components/UserTrend.vue @@ -763,7 +763,14 @@ }, filters:{ rounding (value) { + if(value>=1){ + return "100%" + }else if(value==0){ + return "-" + }else{ return Number(value*100).toFixed(2) + "%" + } + }, transformTimestamp(timestamp){ let a = new Date(timestamp*1000); From dad3c1d4520c5656041396fe80d47fefd142f094 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 14:34:00 +0800 Subject: [PATCH 143/188] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=88=86=E6=9E=90=E7=BB=9F=E8=AE=A1=E6=9C=AA=E6=BF=80=E6=B4=BB?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 6b6bcf233..5b2592764 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -26,7 +26,6 @@ func getUserMetricsExcelHeader(ctx *context.Context) map[string]string { excelHeader = append(excelHeader, ctx.Tr("user.metrics.newregistandactiveuser")) excelHeader = append(excelHeader, ctx.Tr("user.metrics.hasactivateuser")) excelHeader = append(excelHeader, ctx.Tr("user.metrics.newregistnotactiveuser")) - excelHeader = append(excelHeader, ctx.Tr("user.metrics.averageuser")) excelHeader = append(excelHeader, ctx.Tr("user.metrics.newuseractiveindex")) excelHeader = append(excelHeader, ctx.Tr("user.metrics.totalregistuser")) excelHeader = append(excelHeader, ctx.Tr("user.metrics.totalactiveduser")) @@ -57,8 +56,6 @@ func writeUserMetricsExcel(row int, xlsx *excelize.File, sheetName string, userM tmp = tmp + 1 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userMetrics.NotActivateRegistUser) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, "") - tmp = tmp + 1 t := userMetrics.ActivateIndex * 100 value := "-" if t < 100 { From a553e971ba98c4f4a74e176aaf2f0bc7dd2508a0 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 14:38:23 +0800 Subject: [PATCH 144/188] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=88=86=E6=9E=90=E7=BB=9F=E8=AE=A1=E6=9C=AA=E6=BF=80=E6=B4=BB?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 1 + routers/repo/user_data_analysis.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 6e949dd93..86c0cfc13 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -324,6 +324,7 @@ func makeResultForMonth(allUserInfo []*UserMetrics, count int) []*UserMetrics { value.NotActivateRegistUser += userMetrics.NotActivateRegistUser value.HasActivityUser += userMetrics.HasActivityUser value.TotalRegistUser += userMetrics.ActivateRegistUser + userMetrics.NotActivateRegistUser + value.ActivateIndex = float64(value.ActivateRegistUser) / float64(value.TotalRegistUser) value.DaysForMonth += 1 } } diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 5b2592764..d7038103f 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -58,9 +58,9 @@ func writeUserMetricsExcel(row int, xlsx *excelize.File, sheetName string, userM tmp = tmp + 1 t := userMetrics.ActivateIndex * 100 value := "-" - if t < 100 { + if t < 100 && t > 0 { value = fmt.Sprintf("%.2f", t) + "%" - } else { + } else if t >= 100 { value = "100%" } xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, value) From 28314b34482f7926102f15bab438f0d468521465 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 14:47:01 +0800 Subject: [PATCH 145/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index d7038103f..b94762341 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -346,6 +346,7 @@ func QueryUserStaticCurrentMonth(ctx *context.Context) { func getStartTime(pageStartTime time.Time) time.Time { t, _ := time.Parse("2006-01-02", setting.RadarMap.GrowthBeginTime) + t = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 1, t.Location()) if pageStartTime.Before(t) { pageStartTime = t } From 9cdc4bf48490d3f07b27d73706b64107351200d9 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 17 May 2022 15:06:46 +0800 Subject: [PATCH 146/188] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- options/locale/locale_en-US.ini | 2 +- options/locale/locale_zh-CN.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 83a34185a..5f2fb89a2 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1033,7 +1033,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=Failed to generate file. repo_stat_inspect=ProjectAnalysis -repo_stat_develop=ProjectGrowthAnalysis +repo_stat_develop=ProjectTrendAnalysis all=All current_year=Current_Year diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index ff261057f..3de27f380 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -1042,7 +1042,7 @@ get_repo_stat_error=查询当前仓库的统计信息失败。 get_repo_info_error=查询当前仓库信息失败。 generate_statistic_file_error=生成文件失败。 repo_stat_inspect=项目分析 -repo_stat_develop=项目增长趋势 +repo_stat_develop=项目趋势分析 all=所有 current_year=今年 From 7e08b33a86de61ccda470fce4b430c41445c7e55 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 15:08:32 +0800 Subject: [PATCH 147/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index b94762341..7441a8744 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -346,7 +346,7 @@ func QueryUserStaticCurrentMonth(ctx *context.Context) { func getStartTime(pageStartTime time.Time) time.Time { t, _ := time.Parse("2006-01-02", setting.RadarMap.GrowthBeginTime) - t = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 1, t.Location()) + t = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 1, t.UTC().Location()) if pageStartTime.Before(t) { pageStartTime = t } From 30c01546232dd9b9f27e9ebeea24c87b5c693d5f Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 15:16:23 +0800 Subject: [PATCH 148/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 7441a8744..b742fbd8e 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -345,8 +345,8 @@ func QueryUserStaticCurrentMonth(ctx *context.Context) { } func getStartTime(pageStartTime time.Time) time.Time { - t, _ := time.Parse("2006-01-02", setting.RadarMap.GrowthBeginTime) - t = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 1, t.UTC().Location()) + t, _ := time.ParseInLocation("2006-01-02", setting.RadarMap.GrowthBeginTime, time.UTC) + //t = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 1, t.UTC().Location()) if pageStartTime.Before(t) { pageStartTime = t } From 205ea62420383b7dd40abcca827553c8b02f4636 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 15:20:08 +0800 Subject: [PATCH 149/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index b742fbd8e..457ef0736 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -345,8 +345,9 @@ func QueryUserStaticCurrentMonth(ctx *context.Context) { } func getStartTime(pageStartTime time.Time) time.Time { - t, _ := time.ParseInLocation("2006-01-02", setting.RadarMap.GrowthBeginTime, time.UTC) - //t = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 1, t.UTC().Location()) + t, _ := time.ParseInLocation("2006-01-02", setting.RadarMap.GrowthBeginTime, time.Local) + t = t.UTC() + log.Info("t.time=" + fmt.Sprint(t.Unix())) if pageStartTime.Before(t) { pageStartTime = t } From 9d9110272c1928e723150f190541a2f8d06d70bb Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 15:21:17 +0800 Subject: [PATCH 150/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 1 - 1 file changed, 1 deletion(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 457ef0736..82143a57b 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -347,7 +347,6 @@ func QueryUserStaticCurrentMonth(ctx *context.Context) { func getStartTime(pageStartTime time.Time) time.Time { t, _ := time.ParseInLocation("2006-01-02", setting.RadarMap.GrowthBeginTime, time.Local) t = t.UTC() - log.Info("t.time=" + fmt.Sprint(t.Unix())) if pageStartTime.Before(t) { pageStartTime = t } From 9a04933bc33c766d825341d070cb4018818d8e2f Mon Sep 17 00:00:00 2001 From: wangjr Date: Tue, 17 May 2022 15:25:44 +0800 Subject: [PATCH 151/188] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/js/components/UserAnalysis.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index cd465ee2d..784d375fb 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -60,7 +60,7 @@ prop="Name" width="100px"> Date: Tue, 17 May 2022 15:39:59 +0800 Subject: [PATCH 152/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 2 +- routers/repo/user_data_analysis.go | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 86c0cfc13..ca6936904 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -228,7 +228,7 @@ func getLastCountDate() int64 { return pageStartTime.Unix() } -func QueryMetricsPage(start int64, end int64, page int, pageSize int) ([]*UserMetrics, int64) { +func QueryMetricsPage(start int64, end int64) ([]*UserMetrics, int64) { statictisSess := xStatistic.NewSession() defer statictisSess.Close() diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 82143a57b..4a3ff5f38 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -256,14 +256,6 @@ func queryUserDataPage(ctx *context.Context, tableName string, queryObj interfac func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, endTime time.Time) { - page := ctx.QueryInt("page") - if page <= 0 { - page = 1 - } - pageSize := ctx.QueryInt("pageSize") - if pageSize <= 0 { - pageSize = setting.UI.IssuePagingNum - } IsReturnFile := ctx.QueryBool("IsReturnFile") var count int64 @@ -275,7 +267,7 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e result = models.QueryMetricsForAll(startTime.Unix(), endTime.Unix()) count = int64(len(result)) } else { - result, count = models.QueryMetricsPage(startTime.Unix(), endTime.Unix(), page, pageSize) + result, count = models.QueryMetricsPage(startTime.Unix(), endTime.Unix()) } if IsReturnFile { //writer exec file. @@ -297,6 +289,9 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e //设置默认打开的表单 xlsx.SetActiveSheet(index) filename := sheetName + "_" + ctx.Tr("user.static."+tableName) + ".xlsx" + if tableName == "" { + filename = sheetName + "_" + startTime.Format("20060102") + "_" + endTime.Format("20060102") + } ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(filename)) ctx.Resp.Header().Set("Content-Type", "application/octet-stream") if _, err := xlsx.WriteTo(ctx.Resp); err != nil { @@ -433,12 +428,13 @@ func QueryUserMetricDataPage(ctx *context.Context) { if pageSize <= 0 { pageSize = setting.UI.IssuePagingNum } - result, count := models.QueryMetricsPage(startTime.Unix(), endTime.Unix(), page, pageSize) + queryMetrics(ctx, "", startTime, endTime) + // result, count := models.QueryMetricsPage(startTime.Unix(), endTime.Unix(), page, pageSize) - mapInterface := make(map[string]interface{}) - mapInterface["data"] = result - mapInterface["count"] = count - ctx.JSON(http.StatusOK, mapInterface) + // mapInterface := make(map[string]interface{}) + // mapInterface["data"] = result + // mapInterface["count"] = count + // ctx.JSON(http.StatusOK, mapInterface) } func QueryUserStaticDataPage(ctx *context.Context) { From aa2b4de7f88f55242b85a8350b46ef7e7859cecc Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 15:43:57 +0800 Subject: [PATCH 153/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 4a3ff5f38..4def050dc 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -290,7 +290,7 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e xlsx.SetActiveSheet(index) filename := sheetName + "_" + ctx.Tr("user.static."+tableName) + ".xlsx" if tableName == "" { - filename = sheetName + "_" + startTime.Format("20060102") + "_" + endTime.Format("20060102") + filename = sheetName + "_" + startTime.Format("20060102") + "_" + endTime.Format("20060102") + ".xlsx" } ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(filename)) ctx.Resp.Header().Set("Content-Type", "application/octet-stream") @@ -418,23 +418,10 @@ func QueryUserMetricDataPage(ctx *context.Context) { startDate := ctx.Query("startDate") endDate := ctx.Query("endDate") startTime, _ := time.ParseInLocation("2006-01-02", startDate, time.Local) + startTime = startTime.UTC() endTime, _ := time.ParseInLocation("2006-01-02", endDate, time.Local) - - page := ctx.QueryInt("page") - if page <= 0 { - page = 1 - } - pageSize := ctx.QueryInt("pageSize") - if pageSize <= 0 { - pageSize = setting.UI.IssuePagingNum - } + startTime = getStartTime(startTime) queryMetrics(ctx, "", startTime, endTime) - // result, count := models.QueryMetricsPage(startTime.Unix(), endTime.Unix(), page, pageSize) - - // mapInterface := make(map[string]interface{}) - // mapInterface["data"] = result - // mapInterface["count"] = count - // ctx.JSON(http.StatusOK, mapInterface) } func QueryUserStaticDataPage(ctx *context.Context) { From fe62ddcb821fa09de39d0c2450e50ea24d24cdae Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 15:49:53 +0800 Subject: [PATCH 154/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 4def050dc..07b2ad775 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -290,7 +290,7 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e xlsx.SetActiveSheet(index) filename := sheetName + "_" + ctx.Tr("user.static."+tableName) + ".xlsx" if tableName == "" { - filename = sheetName + "_" + startTime.Format("20060102") + "_" + endTime.Format("20060102") + ".xlsx" + filename = sheetName + "_" + startTime.Add(8*60*60*1000).Format("20060102") + "_" + endTime.Add(8*60*60*1000).Format("20060102") + ".xlsx" } ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(filename)) ctx.Resp.Header().Set("Content-Type", "application/octet-stream") From 24d816417017c1f80cd8a2020432f8dd7d652dde Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 15:55:55 +0800 Subject: [PATCH 155/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 07b2ad775..80045a5ad 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -290,7 +290,7 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e xlsx.SetActiveSheet(index) filename := sheetName + "_" + ctx.Tr("user.static."+tableName) + ".xlsx" if tableName == "" { - filename = sheetName + "_" + startTime.Add(8*60*60*1000).Format("20060102") + "_" + endTime.Add(8*60*60*1000).Format("20060102") + ".xlsx" + filename = sheetName + "_" + getTimeFileName(startTime) + "_" + getTimeFileName(endTime) + ".xlsx" } ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(filename)) ctx.Resp.Header().Set("Content-Type", "application/octet-stream") @@ -312,7 +312,17 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e } ctx.JSON(http.StatusOK, mapInterface) } - +} +func getTimeFileName(t time.Time) string { + month := fmt.Sprint(t.Month()) + if t.Month() < 10 { + month = "0" + month + } + day := fmt.Sprint(t.Day()) + if t.Day() < 10 { + day = "0" + day + } + return fmt.Sprint(t.Year()) + month + day } func QueryRankingList(ctx *context.Context) { From 885a1877cec334f9ae160032a9f14bb24999610a Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 16:02:50 +0800 Subject: [PATCH 156/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 80045a5ad..addc37480 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -290,7 +290,7 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e xlsx.SetActiveSheet(index) filename := sheetName + "_" + ctx.Tr("user.static."+tableName) + ".xlsx" if tableName == "" { - filename = sheetName + "_" + getTimeFileName(startTime) + "_" + getTimeFileName(endTime) + ".xlsx" + filename = sheetName + "_" + getTimeFileName(startTime.Add(8*60*60*1000)) + "_" + getTimeFileName(endTime) + ".xlsx" } ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(filename)) ctx.Resp.Header().Set("Content-Type", "application/octet-stream") @@ -314,7 +314,7 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e } } func getTimeFileName(t time.Time) string { - month := fmt.Sprint(t.Month()) + month := fmt.Sprint(int(t.Month())) if t.Month() < 10 { month = "0" + month } From 1a0bb92c80c95ed928ac3e6a5654e3f53206ef3e Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 16:04:43 +0800 Subject: [PATCH 157/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index addc37480..f0a4f4806 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -314,6 +314,7 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e } } func getTimeFileName(t time.Time) string { + log.Info("file time=" + fmt.Sprint(t.Unix())) month := fmt.Sprint(int(t.Month())) if t.Month() < 10 { month = "0" + month From 43ac1475306ee2fa1141439782a899f7dd9437f6 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 16:08:58 +0800 Subject: [PATCH 158/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index f0a4f4806..64be40876 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -290,7 +290,7 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e xlsx.SetActiveSheet(index) filename := sheetName + "_" + ctx.Tr("user.static."+tableName) + ".xlsx" if tableName == "" { - filename = sheetName + "_" + getTimeFileName(startTime.Add(8*60*60*1000)) + "_" + getTimeFileName(endTime) + ".xlsx" + filename = sheetName + "_" + getTimeFileName(startTime) + "_" + getTimeFileName(endTime) + ".xlsx" } ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(filename)) ctx.Resp.Header().Set("Content-Type", "application/octet-stream") @@ -314,6 +314,7 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e } } func getTimeFileName(t time.Time) string { + t = t.Local() log.Info("file time=" + fmt.Sprint(t.Unix())) month := fmt.Sprint(int(t.Month())) if t.Month() < 10 { From 2d55fc4ab56a09b0424ac1717276547f19e7e9c1 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 16:12:23 +0800 Subject: [PATCH 159/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 64be40876..eb333a822 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -315,16 +315,15 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e } func getTimeFileName(t time.Time) string { t = t.Local() - log.Info("file time=" + fmt.Sprint(t.Unix())) - month := fmt.Sprint(int(t.Month())) - if t.Month() < 10 { - month = "0" + month - } - day := fmt.Sprint(t.Day()) - if t.Day() < 10 { - day = "0" + day - } - return fmt.Sprint(t.Year()) + month + day + // month := fmt.Sprint(int(t.Month())) + // if t.Month() < 10 { + // month = "0" + month + // } + // day := fmt.Sprint(t.Day()) + // if t.Day() < 10 { + // day = "0" + day + // } + return t.Format("20060102") } func QueryRankingList(ctx *context.Context) { From a6123b542d61de2329ee20e5d196dfab277ff1e6 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 16:21:09 +0800 Subject: [PATCH 160/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 8 -------- web_src/js/components/UserTrend.vue | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index eb333a822..1bebb9f3e 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -315,14 +315,6 @@ func queryMetrics(ctx *context.Context, tableName string, startTime time.Time, e } func getTimeFileName(t time.Time) string { t = t.Local() - // month := fmt.Sprint(int(t.Month())) - // if t.Month() < 10 { - // month = "0" + month - // } - // day := fmt.Sprint(t.Day()) - // if t.Day() < 10 { - // day = "0" + day - // } return t.Format("20060102") } diff --git a/web_src/js/components/UserTrend.vue b/web_src/js/components/UserTrend.vue index 6b5be7940..efa845e06 100644 --- a/web_src/js/components/UserTrend.vue +++ b/web_src/js/components/UserTrend.vue @@ -24,8 +24,8 @@ 注册用户数 - 未激活:{{ tableDataYesterday.TotalActivateRegistUser}} - 已激活:{{ tableDataYesterday.TotalNotActivateRegistUser }} + 未激活:{{ tableDataYesterday.TotalNotActivateRegistUser }} + 已激活:{{ tableDataYesterday.TotalActivateRegistUser}} 有贡献活动: {{ tableDataYesterday.TotalHasActivityUser}} From dc7512d40de67b81525572e0d620d33391f7f40d Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 17 May 2022 16:30:33 +0800 Subject: [PATCH 161/188] fix issue --- templates/repo/cloudbrain/benchmark/new.tmpl | 6 +++--- templates/repo/cloudbrain/benchmark/show.tmpl | 4 ++-- web_src/js/components/images/Images.vue | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/templates/repo/cloudbrain/benchmark/new.tmpl b/templates/repo/cloudbrain/benchmark/new.tmpl index 393076df3..e2a5e060e 100755 --- a/templates/repo/cloudbrain/benchmark/new.tmpl +++ b/templates/repo/cloudbrain/benchmark/new.tmpl @@ -116,8 +116,8 @@ data-content={{.i18n.Tr "repo.modelarts.train_job.boot_file_helper"}} data-position="right center" data-variation="mini"> - {{.i18n.Tr "cloudbrain.view_sample"}} + {{.i18n.Tr "cloudbrain.view_sample"}}
@@ -307,7 +307,7 @@ } document.onreadystatechange = function () { if (document.readyState === "complete") { - if ($('input[name=benchmarkMode]').val() === 'alogrithm') { + if ($('input[name=benchmarkMode]').val() === 'alogrithm' || $('input[name=benchmarkMode]').val() === '') { setChildType(); } } diff --git a/templates/repo/cloudbrain/benchmark/show.tmpl b/templates/repo/cloudbrain/benchmark/show.tmpl index 2a2404f7c..f3216c884 100755 --- a/templates/repo/cloudbrain/benchmark/show.tmpl +++ b/templates/repo/cloudbrain/benchmark/show.tmpl @@ -221,8 +221,8 @@
{{range $k ,$v := .version_list_task}} -
+
diff --git a/web_src/js/components/images/Images.vue b/web_src/js/components/images/Images.vue index 2a42b8b9e..ac71fb370 100644 --- a/web_src/js/components/images/Images.vue +++ b/web_src/js/components/images/Images.vue @@ -370,9 +370,10 @@ align="center" > Date: Tue, 17 May 2022 16:42:17 +0800 Subject: [PATCH 162/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index ca6936904..44b67d390 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -669,7 +669,7 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS log.Info("insert all data failed." + err.Error()) } } - + log.Info("TotalHasActivityUser=" + fmt.Sprint(userMetrics["TotalHasActivityUser"])) //normalization for k, v := range userIndexMap { tmpResult := (v - minUserIndex) / (maxUserIndex - minUserIndex) @@ -868,6 +868,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, dateRecord.UserIndexPrimitive = getUserIndex(dateRecord, ParaWeight) setUserMetrics(userMetrics, userRecord, start_unix, end_unix, dateRecord) if getUserActivate(dateRecord) > 0 { + log.Info("has activity." + userRecord.Name) addUserToMap(userNewAddActivity, userRecord.CreatedUnix, dateRecord.ID) } if userRecord.IsActive { From 8452767b9fd7b53a9d82840053ec62a7c30c7f9a Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 17 May 2022 16:43:09 +0800 Subject: [PATCH 163/188] revert --- modules/cloudbrain/cloudbrain.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/cloudbrain/cloudbrain.go b/modules/cloudbrain/cloudbrain.go index 214897789..3dee3a3fa 100755 --- a/modules/cloudbrain/cloudbrain.go +++ b/modules/cloudbrain/cloudbrain.go @@ -1,12 +1,10 @@ package cloudbrain import ( + "code.gitea.io/gitea/modules/timeutil" "encoding/json" "errors" "strconv" - "strings" - - "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/storage" @@ -190,7 +188,7 @@ func AdminOrImageCreaterRight(ctx *context.Context) { func GenerateTask(ctx *context.Context, displayJobName, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, brainScorePath, jobType, gpuQueue, description, branchName, bootFile, params string, benchmarkTypeID, benchmarkChildTypeID, resourceSpecId int) error { - image = strings.TrimSpace(image) + dataActualPath := setting.Attachment.Minio.RealPath + setting.Attachment.Minio.Bucket + "/" + setting.Attachment.Minio.BasePath + From cfc455d33337f73088f9e941eada77fa2e5ae08f Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 16:43:19 +0800 Subject: [PATCH 164/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 44b67d390..bcbcd57cf 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -669,7 +669,9 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS log.Info("insert all data failed." + err.Error()) } } - log.Info("TotalHasActivityUser=" + fmt.Sprint(userMetrics["TotalHasActivityUser"])) + if tableName == "user_business_analysis_all" { + log.Info("TotalHasActivityUser=" + fmt.Sprint(userMetrics["TotalHasActivityUser"])) + } //normalization for k, v := range userIndexMap { tmpResult := (v - minUserIndex) / (maxUserIndex - minUserIndex) From 3de9251716606cd7c890057e5aa80944215fb598 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 16:45:09 +0800 Subject: [PATCH 165/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index bcbcd57cf..0334b5715 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -652,7 +652,7 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS dateRecordBatch = make([]UserBusinessAnalysisAll, 0) } if tableName == "user_business_analysis_all" { - if dateRecordAll.UserIndex > 0 || dateRecordAll.LoginCount > 0 { + if getUserActivateAll(dateRecordAll) > 0 { userMetrics["TotalHasActivityUser"] = getMapKeyStringValue("TotalHasActivityUser", userMetrics) + 1 } } @@ -1038,6 +1038,27 @@ func getUserIndexFromAnalysisAll(dateRecord UserBusinessAnalysisAll, ParaWeight return result } +func getUserActivateAll(dateRecord UserBusinessAnalysisAll) int { + var result int + result += dateRecord.CodeMergeCount + result += dateRecord.CommitCount + result += dateRecord.IssueCount + result += dateRecord.CommentCount + result += dateRecord.FocusRepoCount + result += dateRecord.StarRepoCount + result += dateRecord.SolveIssueCount + result += dateRecord.EncyclopediasCount + result += dateRecord.CreateRepoCount + result += dateRecord.CloudBrainTaskNum + result += dateRecord.CommitModelCount + result += dateRecord.CommitDatasetNum + result += dateRecord.FocusOtherUser + result += dateRecord.CollectDataset + result += dateRecord.CollectImage + result += dateRecord.CommitCodeSize + return result +} + func getUserActivate(dateRecord UserBusinessAnalysis) int { var result int result += dateRecord.CodeMergeCount From b3ab3723d34d188d89995e8508b54ccd394809a8 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 17 May 2022 16:51:06 +0800 Subject: [PATCH 166/188] fix issue --- templates/admin/cloudbrain/list.tmpl | 179 ++++++++++++++++++--------- 1 file changed, 119 insertions(+), 60 deletions(-) diff --git a/templates/admin/cloudbrain/list.tmpl b/templates/admin/cloudbrain/list.tmpl index 60c3510a5..0c049ad48 100755 --- a/templates/admin/cloudbrain/list.tmpl +++ b/templates/admin/cloudbrain/list.tmpl @@ -1,6 +1,6 @@ {{template "base/head" .}} - -
+ +
@@ -12,21 +12,26 @@
- + {{template "admin/navbar" .}}
{{template "base/alert" .}} -
+
{{template "admin/cloudbrain/search" .}}
- +
@@ -39,13 +44,13 @@ {{$.i18n.Tr "repo.modelarts.status"}}
- {{$.i18n.Tr "repo.modelarts.createtime"}} + {{$.i18n.Tr "repo.modelarts.createtime"}}
{{$.i18n.Tr "repo.cloudbrain_status_runtime"}}
- {{$.i18n.Tr "repo.modelarts.computing_resources"}} + {{$.i18n.Tr "repo.modelarts.computing_resources"}}
{{$.i18n.Tr "repo.cloudbrain_creator"}} @@ -75,20 +80,32 @@
{{if or (eq .JobType "DEBUG") (eq .JobType "SNN4IMAGENET") (eq .JobType "BRAINSCORE")}} - - {{.DisplayJobName}} + + {{.DisplayJobName}} {{else if eq .JobType "INFERENCE"}} - - {{.DisplayJobName}} + + {{.DisplayJobName}} {{else if eq .JobType "TRAIN"}} - - {{.DisplayJobName}} + + {{.DisplayJobName}} {{else if eq .JobType "BENCHMARK"}} - - {{.DisplayJobName}} + + {{.DisplayJobName}} {{end}}
@@ -97,50 +114,68 @@ {{.JobType}}
-
- - {{.Status}} +
+ + {{.Status}}
- {{TimeSinceUnix1 .Cloudbrain.CreatedUnix}} + {{TimeSinceUnix1 .Cloudbrain.CreatedUnix}}
- {{if .TrainJobDuration}}{{.TrainJobDuration}}{{else}}--{{end}} + {{if .TrainJobDuration}}{{.TrainJobDuration}}{{else}}--{{end}}
- {{if .ComputeResource}}{{.ComputeResource}}{{else}}--{{end}} + {{if .ComputeResource}}{{.ComputeResource}}{{else}}--{{end}}
{{if .User.Name}} - + {{else}} - + {{end}}
-
+
{{.JobName}}
- {{if eq .JobType "DEBUG" "SNN4IMAGENET" "BRAINSCORE"}} + {{if eq .JobType "DEBUG"}}
{{$.CsrfTokenHtml}} {{if eq .Status "RUNNING" "WAITING" "CREATING" "STARTING"}} - + {{$.i18n.Tr "repo.debug"}} {{else}} - + {{$.i18n.Tr "repo.debug_again"}} {{end}} @@ -150,22 +185,33 @@
{{if eq .JobType "DEBUG" "BENCHMARK" "SNN4IMAGENET" "BRAINSCORE"}} - + {{$.CsrfTokenHtml}} - + {{$.i18n.Tr "repo.stop"}} {{else}} - + {{$.i18n.Tr "repo.stop"}} {{end}}
-
+ {{$.CsrfTokenHtml}} - + {{$.i18n.Tr "repo.delete"}}
@@ -185,19 +231,23 @@
{{if eq .JobType "DEBUG"}} - {{.DisplayJobName}} + {{.DisplayJobName}} {{else if eq .JobType "INFERENCE"}} - {{.DisplayJobName}} + {{.DisplayJobName}} {{else if eq .JobType "TRAIN"}} - {{.DisplayJobName}} + {{.DisplayJobName}} {{else if eq .JobType "BENCHMARK"}} - {{.DisplayJobName}} + {{.DisplayJobName}} {{end}}
@@ -206,29 +256,38 @@ {{.JobType}}
-
- - {{.Status}} +
+ + {{.Status}}
- {{TimeSinceUnix1 .Cloudbrain.CreatedUnix}} + {{TimeSinceUnix1 .Cloudbrain.CreatedUnix}}
- {{if .TrainJobDuration}}{{.TrainJobDuration}}{{else}}--{{end}} + {{if .TrainJobDuration}}{{.TrainJobDuration}}{{else}}--{{end}}
- {{if .ComputeResource}}{{.ComputeResource}}{{else}}--{{end}} + {{if .ComputeResource}}{{.ComputeResource}}{{else}}--{{end}}
{{if .User.Name}} - + {{else}} - + {{end}}
@@ -236,7 +295,8 @@ --
-
+
{{.JobName}}
@@ -245,11 +305,12 @@
{{$.CsrfTokenHtml}} {{if eq .Status "RUNNING" "WAITING" "CREATING" "STARTING"}} - + {{$.i18n.Tr "repo.debug"}} {{else}} - + {{$.i18n.Tr "repo.debug_again"}} {{end}} @@ -258,14 +319,17 @@ {{end}} {{$.CsrfTokenHtml}} - + {{$.i18n.Tr "repo.delete"}}
@@ -277,14 +341,9 @@ {{end}}
- +
From e7d6e9f50fd9bd47c5d8f14dd72357dacf43f68a Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 16:55:19 +0800 Subject: [PATCH 167/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 0334b5715..f292f0b01 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -652,7 +652,9 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS dateRecordBatch = make([]UserBusinessAnalysisAll, 0) } if tableName == "user_business_analysis_all" { - if getUserActivateAll(dateRecordAll) > 0 { + tValue := getUserActivateAll(dateRecordAll) + if tValue > 0 { + log.Info("dateRecordAll name=" + dateRecordAll.Name + " value=" + fmt.Sprint(tValue)) userMetrics["TotalHasActivityUser"] = getMapKeyStringValue("TotalHasActivityUser", userMetrics) + 1 } } From 9e0f5869569b03ed6616ac7c263fedc6f2b9418f Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 17:00:22 +0800 Subject: [PATCH 168/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index f292f0b01..db7f6855b 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -1,6 +1,7 @@ package models import ( + "encoding/json" "fmt" "sort" "strconv" @@ -778,6 +779,8 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, log.Info("query commit code errr.") } else { log.Info("query commit code size, len=" + fmt.Sprint(len(CommitCodeSizeMap))) + CommitCodeSizeMapJson, _ := json.Marshal(CommitCodeSizeMap) + log.Info("CommitCodeSizeMapJson=" + string(CommitCodeSizeMapJson)) } CommitDatasetSizeMap, CommitDatasetNumMap := queryDatasetSize(start_unix, end_unix) SolveIssueCountMap := querySolveIssue(start_unix, end_unix) From c59bff083e1cf4c0146d30b6031de127c53abfb4 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 17:20:49 +0800 Subject: [PATCH 169/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- web_src/js/components/UserTrend.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web_src/js/components/UserTrend.vue b/web_src/js/components/UserTrend.vue index efa845e06..cdfdf2a24 100644 --- a/web_src/js/components/UserTrend.vue +++ b/web_src/js/components/UserTrend.vue @@ -13,7 +13,7 @@ 昨日新增注册用户数 未激活:{{ tableDataYesterday.NotActivateRegistUser }} 已激活: {{ tableDataYesterday.ActivateRegistUser }} - 有贡献活动: {{ tableDataYesterday.RegistActivityUser }} + 有贡献活动: {{ tableDataYesterday.HasActivityUser }} @@ -114,7 +114,7 @@ align="center"> @@ -292,7 +292,7 @@ switch(type_val){ case "yesterday_usr":{ this.value_time=[] - this.dataUrl = '../../api/v1/query_user_yesterday'; + this.dataUrl = '../../api/v1/query_metrics_yesterday'; break } case "current_week_usr":{ @@ -517,7 +517,7 @@ xdata.push(this.tableData[this.tableData.length-1-i].DisplayDate); ydata_TotalRegistUser.push(this.tableData[this.tableData.length-1-i].TotalRegistUser) ydata_ActivateRegistUser.push(this.tableData[this.tableData.length-1-i].ActivateRegistUser) - ydata_RegistActivityUser.push(this.tableData[this.tableData.length-1-i].RegistActivityUser) + ydata_RegistActivityUser.push(this.tableData[this.tableData.length-1-i].HasActivityUser) ydata_NotActivateRegistUser.push(this.tableData[this.tableData.length-1-i].NotActivateRegistUser) ydata_TotalUser.push(this.tableData[this.tableData.length-1-i].TotalUser) ydata_TotalActivateRegistUser.push(this.tableData[this.tableData.length-1-i].TotalActivateRegistUser) From 41cf2e676622246b41071dd744b2d59a9676070c Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 17 May 2022 17:26:40 +0800 Subject: [PATCH 170/188] fix issue --- templates/admin/cloudbrain/list.tmpl | 9 ++++++++- templates/repo/view_list.tmpl | 4 ++-- web_src/js/features/contexmenu.js | 2 +- web_src/less/openi.less | 26 ++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/templates/admin/cloudbrain/list.tmpl b/templates/admin/cloudbrain/list.tmpl index 0c049ad48..4c63b167a 100755 --- a/templates/admin/cloudbrain/list.tmpl +++ b/templates/admin/cloudbrain/list.tmpl @@ -79,13 +79,20 @@ {{end}}
- {{if or (eq .JobType "DEBUG") (eq .JobType "SNN4IMAGENET") (eq .JobType "BRAINSCORE")}} + {{if eq .JobType "DEBUG"}} {{.DisplayJobName}} + {{else if or (eq .JobType "SNN4IMAGENET") (eq .JobType "BRAINSCORE")}} + + {{.DisplayJobName}} + {{else if eq .JobType "INFERENCE"}} - .context-menu { + .context-menu-click { z-index: 99; position: absolute; padding: 0; @@ -11,7 +11,7 @@ display: none !important; } - .context-menu.active { + .context-menu-click.active { display: block !important; } diff --git a/web_src/js/features/contexmenu.js b/web_src/js/features/contexmenu.js index 318a4c25f..ff827060b 100644 --- a/web_src/js/features/contexmenu.js +++ b/web_src/js/features/contexmenu.js @@ -92,7 +92,7 @@ export default async function initContextMenu() { class Menu { constructor(param) { this.target = document.createElement('div') - this.target.classList.add("ui", "menu", "compact", "vertical", "context-menu") + this.target.classList.add("ui", "menu", "compact", "vertical", "context-menu-click") this.data = param.data this.active = false this.clickZ = this.click.bind(this) diff --git a/web_src/less/openi.less b/web_src/less/openi.less index 2a7d86665..6d0daba19 100644 --- a/web_src/less/openi.less +++ b/web_src/less/openi.less @@ -1025,4 +1025,30 @@ display: block; z-index: 9999; width:150; height: 80; +} + +.context-menu-click { + z-index: 99; + position: absolute; + padding: 0; + border-radius: 4px; + border: 1px solid #e3e9ed; + -webkit-box-shadow: none; + box-shadow: none; + background: #fff; + display: none !important; +} + +.context-menu-click.active { + display: block !important; +} + +.context-menu-operation { + padding: 5px !important; + line-height: 1.78 !important; +} + +.context-menu-icon { + float: left !important; + margin: 0px 5px 0px 0px !important; } \ No newline at end of file From ce015f950bc3904ac331d18ff9bd0a049c8e9751 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 17 May 2022 17:27:55 +0800 Subject: [PATCH 171/188] fix issue --- templates/repo/view_list.tmpl | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index d1ddcdc55..39300dcfa 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -1,30 +1,3 @@ -
From d1b3cee173b3b80f67b1c561e5bf8c13e906ad03 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 17 May 2022 17:34:12 +0800 Subject: [PATCH 172/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=AD=A3SQL=E8=AF=AD=E5=8F=A5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index db7f6855b..56e591dea 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -896,7 +896,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, } RefreshUserStaticAllTabel(wikiCountMap, userMetrics) - + log.Info("start to update UserMetrics") //insert userMetrics table var useMetrics UserMetrics useMetrics.CountDate = CountDate.Unix() @@ -946,7 +946,7 @@ func updateNewUserAcitivity(currentUserActivity map[int64]map[int64]int64, stati if len(userIdArray) > 0 { useMetrics.HasActivityUserJson = userIdArray[0 : len(userIdArray)-1] } - updateSql := "update public.user_metrics set has_activity_user_json=" + useMetrics.HasActivityUserJson + ",regist_activity_user=" + fmt.Sprint(useMetrics.HasActivityUser) + " where count_date=" + fmt.Sprint(key) + updateSql := "update public.user_metrics set has_activity_user_json='" + useMetrics.HasActivityUserJson + "',regist_activity_user=" + fmt.Sprint(useMetrics.HasActivityUser) + " where count_date=" + fmt.Sprint(key) statictisSess.Exec(updateSql) } } From edd9c3652298a627d76ff7479c0ac4c5ea6fdcbb Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 17 May 2022 18:00:22 +0800 Subject: [PATCH 173/188] fix issue --- templates/repo/cloudbrain/benchmark/show.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/repo/cloudbrain/benchmark/show.tmpl b/templates/repo/cloudbrain/benchmark/show.tmpl index f3216c884..d339e127b 100755 --- a/templates/repo/cloudbrain/benchmark/show.tmpl +++ b/templates/repo/cloudbrain/benchmark/show.tmpl @@ -406,7 +406,7 @@
- {{if eq .BenchmarkType "Benchmark"}} + {{if eq .JobType "BENCHMARK"}} train.py {{else}} -- @@ -421,7 +421,7 @@
- {{if eq .BenchmarkType "Benchmark"}} + {{if eq .JobType "BENCHMARK"}} test.py {{else}} -- From bc053d5b269016ab9c965f361a1118e1cc94e688 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 17 May 2022 18:02:27 +0800 Subject: [PATCH 174/188] fix issue --- templates/repo/cloudbrain/benchmark/show.tmpl | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/repo/cloudbrain/benchmark/show.tmpl b/templates/repo/cloudbrain/benchmark/show.tmpl index d339e127b..cc4793a9b 100755 --- a/templates/repo/cloudbrain/benchmark/show.tmpl +++ b/templates/repo/cloudbrain/benchmark/show.tmpl @@ -566,7 +566,6 @@ {{template "base/footer" .}} + \ No newline at end of file diff --git a/templates/user/dashboard/cloudbrains.tmpl b/templates/user/dashboard/cloudbrains.tmpl index 9abee857c..3c16bad04 100644 --- a/templates/user/dashboard/cloudbrains.tmpl +++ b/templates/user/dashboard/cloudbrains.tmpl @@ -1,6 +1,6 @@ {{template "base/head" .}} - -
+ +
@@ -12,20 +12,22 @@
- {{template "admin/cloudbrain/search_dashboard" .}}
{{template "base/alert" .}} -
-
+
+
- +
@@ -38,19 +40,19 @@ {{$.i18n.Tr "repo.cloudbrain_task_type"}}
- {{$.i18n.Tr "repo.modelarts.createtime"}} + {{$.i18n.Tr "repo.modelarts.createtime"}}
{{$.i18n.Tr "repo.cloudbrain_status_runtime"}}
- {{$.i18n.Tr "repo.modelarts.computing_resources"}} + {{$.i18n.Tr "repo.modelarts.computing_resources"}}
- +
{{$.i18n.Tr "repository"}}
- +
{{$.i18n.Tr "repo.cloudbrain_operate"}}
@@ -69,66 +71,100 @@ {{end}}
- + -
- - {{.Status}} +
+ + {{.Status}}
- + {{$JobType := $.i18n.Tr (printf "cloudbrain.%s" .JobType)}}
{{$JobType}}
- {{TimeSinceUnix1 .Cloudbrain.CreatedUnix}} + {{TimeSinceUnix1 .Cloudbrain.CreatedUnix}}
- {{if .TrainJobDuration}}{{.TrainJobDuration}}{{else}}--{{end}} + {{if .TrainJobDuration}}{{.TrainJobDuration}}{{else}}--{{end}}
- {{if .ComputeResource}}{{.ComputeResource}}{{else}}--{{end}} + {{if .ComputeResource}}{{.ComputeResource}}{{else}}--{{end}}
- + - +
{{if eq .JobType "DEBUG"}}
{{$.CsrfTokenHtml}} {{if eq .Status "RUNNING" "WAITING" "CREATING" "STARTING"}} - + {{$.i18n.Tr "repo.debug"}} {{else}} - + {{$.i18n.Tr "repo.debug_again"}} {{end}} @@ -138,30 +174,42 @@
{{if eq .JobType "DEBUG" "BENCHMARK" "SNN4IMAGENET" "BRAINSCORE"}} - + {{$.CsrfTokenHtml}} - + {{$.i18n.Tr "repo.stop"}} {{else}} - + {{$.i18n.Tr "repo.stop"}} {{end}}
{{if eq .JobType "BENCHMARK"}} - + {{end}} -
+ {{$.CsrfTokenHtml}} - + {{$.i18n.Tr "repo.delete"}}
@@ -181,27 +229,35 @@
{{if eq .JobType "DEBUG"}} - {{.DisplayJobName}} + {{.DisplayJobName}} {{else if eq .JobType "INFERENCE"}} - {{.DisplayJobName}} + {{.DisplayJobName}} {{else if eq .JobType "TRAIN"}} - {{.DisplayJobName}} + {{.DisplayJobName}} {{else if eq .JobType "BENCHMARK"}} - {{.DisplayJobName}} + {{.DisplayJobName}} {{end}}
- + -
- - {{.Status}} +
+ + {{.Status}}
@@ -211,18 +267,21 @@
- {{TimeSinceUnix1 .Cloudbrain.CreatedUnix}} + {{TimeSinceUnix1 .Cloudbrain.CreatedUnix}}
- {{if .TrainJobDuration}}{{.TrainJobDuration}}{{else}}--{{end}} + {{if .TrainJobDuration}}{{.TrainJobDuration}}{{else}}--{{end}}
- {{if .ComputeResource}}{{.ComputeResource}}{{else}}--{{end}} + {{if .ComputeResource}}{{.ComputeResource}}{{else}}--{{end}}
- +
-- @@ -233,11 +292,12 @@
{{$.CsrfTokenHtml}} {{if eq .Status "RUNNING" "WAITING" "CREATING" "STARTING"}} - + {{$.i18n.Tr "repo.debug"}} {{else}} - + {{$.i18n.Tr "repo.debug_again"}} {{end}} @@ -246,14 +306,17 @@ {{end}} {{$.CsrfTokenHtml}} - + {{$.i18n.Tr "repo.delete"}}
@@ -265,14 +328,9 @@ {{end}}
- +
From 877850c0806d12aa58869c68f1210ac12726d693 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 18 May 2022 15:50:49 +0800 Subject: [PATCH 181/188] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=89=93=E5=8D=B0=EF=BC=8Ctrim=E9=95=9C=E5=83=8F=E6=8F=90?= =?UTF-8?q?=E4=BA=A4tag=E7=9A=84=E5=89=8D=E5=90=8E=E7=A9=BA=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/cloudbrain/resty.go | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/modules/cloudbrain/resty.go b/modules/cloudbrain/resty.go index 1565d3044..b5b86f31f 100755 --- a/modules/cloudbrain/resty.go +++ b/modules/cloudbrain/resty.go @@ -213,8 +213,9 @@ func getQueryString(page int, size int, name string) string { } func CommitImage(jobID string, params models.CommitImageParams) error { + imageTag := strings.TrimSpace(params.ImageTag) - dbImage, err := models.GetImageByTag(params.ImageTag) + dbImage, err := models.GetImageByTag(imageTag) if err != nil && !models.IsErrImageNotExist(err) { return fmt.Errorf("resty CommitImage: %v", err) @@ -224,12 +225,12 @@ func CommitImage(jobID string, params models.CommitImageParams) error { if dbImage != nil { if dbImage.UID != params.UID { return models.ErrorImageTagExist{ - Tag: params.ImageTag, + Tag: imageTag, } } else { if dbImage.Status == models.IMAGE_STATUS_COMMIT { return models.ErrorImageCommitting{ - Tag: params.ImageTag, + Tag: imageTag, } } else { //覆盖提交 @@ -282,9 +283,9 @@ sendjob: CloudbrainType: params.CloudBrainType, UID: params.UID, IsPrivate: params.IsPrivate, - Tag: params.ImageTag, + Tag: imageTag, Description: params.ImageDescription, - Place: setting.Cloudbrain.ImageURLPrefix + params.ImageTag, + Place: setting.Cloudbrain.ImageURLPrefix + imageTag, Status: models.IMAGE_STATUS_COMMIT, } @@ -318,15 +319,15 @@ sendjob: } func CommitAdminImage(params models.CommitImageParams) error { - - exist, err := models.IsImageExist(params.ImageTag) + imageTag := strings.TrimSpace(params.ImageTag) + exist, err := models.IsImageExist(imageTag) if err != nil { return fmt.Errorf("resty CommitImage: %v", err) } if exist { return models.ErrorImageTagExist{ - Tag: params.ImageTag, + Tag: imageTag, } } @@ -334,7 +335,7 @@ func CommitAdminImage(params models.CommitImageParams) error { CloudbrainType: params.CloudBrainType, UID: params.UID, IsPrivate: params.IsPrivate, - Tag: params.ImageTag, + Tag: imageTag, Description: params.ImageDescription, Place: params.Place, Status: models.IMAGE_STATUS_SUCCESS, @@ -362,13 +363,11 @@ func updateImageStatus(image models.Image, isSetCreatedUnix bool, createTime tim commitSuccess := false time.Sleep(5 * time.Second) for i := 0; i < attemps; i++ { - - if commitSuccess { - break - } - + log.Info("the " + strconv.Itoa(i) + " times query cloudbrain images.Imagetag:" + image.Tag + "isSetCreate:" + strconv.FormatBool(isSetCreatedUnix)) result, err := GetImagesPageable(1, pageSize, Custom, "") if err == nil && result.Code == "S000" { + + log.Info("images count:" + strconv.Itoa(result.Payload.Count)) for _, v := range result.Payload.ImageInfo { if v.Place == image.Place && (!isSetCreatedUnix || (isSetCreatedUnix && createTimeUpdated(v, createTime))) { image.Status = models.IMAGE_STATUS_SUCCESS @@ -380,6 +379,10 @@ func updateImageStatus(image models.Image, isSetCreatedUnix bool, createTime tim } } + + if commitSuccess { + break + } //第一次循环等待4秒,第二次等待4的2次方16秒,...,第5次。。。 ,总共大概是20多分钟内进行5次重试 var sleepTime = time.Duration(int(math.Pow(4, (float64(i + 1))))) From 90eb6f91e74e3b67decc5e2957fa8702ffdb4c7e Mon Sep 17 00:00:00 2001 From: Gitea Date: Wed, 18 May 2022 20:32:54 +0800 Subject: [PATCH 182/188] fix issue --- web_src/less/openi.less | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web_src/less/openi.less b/web_src/less/openi.less index 918e4cd0c..de2a3fe8c 100644 --- a/web_src/less/openi.less +++ b/web_src/less/openi.less @@ -1029,6 +1029,7 @@ display: block; .ui.toast-container .toast-box.compact, .ui.toast-container .toast-box>.compact { width: 250px !important; +} .context-menu-click { z-index: 99; position: absolute; @@ -1053,4 +1054,4 @@ display: block; .context-menu-icon { float: left !important; margin: 0px 5px 0px 0px !important; -} \ No newline at end of file +} From 159fe2bfeb0b5cfef1b2113928e85240fc6c4393 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Thu, 19 May 2022 08:56:43 +0800 Subject: [PATCH 183/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E9=95=9C=E5=83=8F?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4=E6=94=B9=E4=B8=BA20?= =?UTF-8?q?=E5=88=86=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/cloudbrain/resty.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/cloudbrain/resty.go b/modules/cloudbrain/resty.go index b5b86f31f..e70dbdd2b 100755 --- a/modules/cloudbrain/resty.go +++ b/modules/cloudbrain/resty.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "fmt" - "math" "net/http" "strconv" "strings" @@ -359,10 +358,11 @@ func CommitAdminImage(params models.CommitImageParams) error { } func updateImageStatus(image models.Image, isSetCreatedUnix bool, createTime time.Time) { - attemps := 5 + attemps := 60 commitSuccess := false - time.Sleep(5 * time.Second) + for i := 0; i < attemps; i++ { + time.Sleep(20 * time.Second) log.Info("the " + strconv.Itoa(i) + " times query cloudbrain images.Imagetag:" + image.Tag + "isSetCreate:" + strconv.FormatBool(isSetCreatedUnix)) result, err := GetImagesPageable(1, pageSize, Custom, "") if err == nil && result.Code == "S000" { @@ -383,10 +383,6 @@ func updateImageStatus(image models.Image, isSetCreatedUnix bool, createTime tim if commitSuccess { break } - //第一次循环等待4秒,第二次等待4的2次方16秒,...,第5次。。。 ,总共大概是20多分钟内进行5次重试 - var sleepTime = time.Duration(int(math.Pow(4, (float64(i + 1))))) - - time.Sleep(sleepTime * time.Second) } if !commitSuccess { From 7f02d022880438315399d556fa537ad1b4fed51e Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 19 May 2022 10:58:09 +0800 Subject: [PATCH 184/188] fix issue --- templates/repo/cloudbrain/benchmark/show.tmpl | 2 +- web_src/js/features/contexmenu.js | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/templates/repo/cloudbrain/benchmark/show.tmpl b/templates/repo/cloudbrain/benchmark/show.tmpl index 4ad5c44c4..c79f6f268 100755 --- a/templates/repo/cloudbrain/benchmark/show.tmpl +++ b/templates/repo/cloudbrain/benchmark/show.tmpl @@ -485,7 +485,7 @@
- {{if .User.Name}} + {{if .User}} {{.User.Name}} {{else}} -- diff --git a/web_src/js/features/contexmenu.js b/web_src/js/features/contexmenu.js index ff827060b..23494d480 100644 --- a/web_src/js/features/contexmenu.js +++ b/web_src/js/features/contexmenu.js @@ -40,7 +40,8 @@ export default async function initContextMenu() { if (a.currentTarget.parentNode.nextElementSibling) { a.currentTarget.parentNode.style.setProperty('display', 'none', 'important') a.currentTarget.parentNode.nextElementSibling.style.display = 'table-row' - a.currentTarget.parentNode.nextElementSibling.getElementsByTagName("input")[0].setAttribute("value", a.currentTarget.getElementsByTagName("a")[0].getAttribute('title')) + let renameFile = a.currentTarget.getElementsByTagName("a")[0].getAttribute('title') + a.currentTarget.parentNode.nextElementSibling.getElementsByTagName("input")[0].setAttribute("value", renameFile.substr(0, renameFile.indexOf('/'))) } let btn = a.currentTarget.parentNode.nextElementSibling.getElementsByTagName("button")[0] @@ -55,9 +56,6 @@ export default async function initContextMenu() { contentType: "application/x-www-form-urlencoded", data: { last_commit: last_commit, tree_path: tree_path, _csrf: csrf }, success: function (res) { - console.log("--------------") - console.log(res.Code) - console.log(res.Message) if (res.Code === 0) { document.getElementById("mask").style.display = "block" location.reload() From a3c4ae3b80054f9387d87f529eab9d45c5f119b3 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 19 May 2022 11:17:29 +0800 Subject: [PATCH 185/188] fix issue --- web_src/js/features/contexmenu.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web_src/js/features/contexmenu.js b/web_src/js/features/contexmenu.js index 23494d480..b357af71b 100644 --- a/web_src/js/features/contexmenu.js +++ b/web_src/js/features/contexmenu.js @@ -40,8 +40,9 @@ export default async function initContextMenu() { if (a.currentTarget.parentNode.nextElementSibling) { a.currentTarget.parentNode.style.setProperty('display', 'none', 'important') a.currentTarget.parentNode.nextElementSibling.style.display = 'table-row' - let renameFile = a.currentTarget.getElementsByTagName("a")[0].getAttribute('title') - a.currentTarget.parentNode.nextElementSibling.getElementsByTagName("input")[0].setAttribute("value", renameFile.substr(0, renameFile.indexOf('/'))) + const renameFile = a.currentTarget.getElementsByTagName("a")[0].getAttribute('title') + let renameFileValue = renameFile.indexOf('/') !== -1 ? renameFile.substr(0, renameFile.indexOf('/')) : renameFile + a.currentTarget.parentNode.nextElementSibling.getElementsByTagName("input")[0].setAttribute("value", renameFileValue) } let btn = a.currentTarget.parentNode.nextElementSibling.getElementsByTagName("button")[0] From c52a32952fda3de8b3a3223dc4ef709678a644e0 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 19 May 2022 14:23:27 +0800 Subject: [PATCH 186/188] #2133 fix bug --- options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 1 + routers/repo/editor.go | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 4a5c6afd7..ef3ad7705 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1311,6 +1311,7 @@ editor.directory_is_a_file = Directory name '%s' is already used as a filename i editor.file_is_a_symlink = '%s' is a symbolic link. Symbolic links cannot be edited in the web editor editor.filename_is_a_directory = Filename '%s' is already used as a directory name in this repository. editor.file_editing_no_longer_exists = The file being edited, '%s', no longer exists in this repository. +editor.file_or_directory_editing_no_longer_exists = The file or directory being edited, '%s', no longer exists in this repository. editor.file_deleting_no_longer_exists = The file being deleted, '%s', no longer exists in this repository. editor.file_changed_while_editing = The file contents have changed since you started editing. Click here to see them or Commit Changes again to overwrite them. editor.file_already_exists = A file named '%s' already exists in this repository. diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 7d70b945f..2f0bbe91d 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -1323,6 +1323,7 @@ editor.directory_is_a_file='%s' 已经作为文件名在此项目中存在。 editor.file_is_a_symlink='%s' 是一个符号链接,无法在线编辑。 editor.filename_is_a_directory='%s' 已经作为目录名在此项目中存在。 editor.file_editing_no_longer_exists=正在编辑的文件 '%s' 已不存在。 +editor.file_or_directory_editing_no_longer_exists=正在编辑的文件或文件夹 '%s' 已不存在。 editor.file_deleting_no_longer_exists=项目中不存在将被删除的文件‘%s’。 editor.file_changed_while_editing=文件内容在您进行编辑时已经发生变动。单击此处 查看变动的具体内容,或者 再次提交 覆盖已发生的变动。 editor.file_already_exists=此项目已经存在名为 '%s' 的文件。 diff --git a/routers/repo/editor.go b/routers/repo/editor.go index b389759f5..40edc4767 100644 --- a/routers/repo/editor.go +++ b/routers/repo/editor.go @@ -839,9 +839,9 @@ func renameFilePost(ctx *context.Context, form auth.RenameRepoFileForm) { }); err != nil { // This is where we handle all the errors thrown by repofiles.CreateOrUpdateRepoFile if git.IsErrNotExist(err) { - ctx.JSON(http.StatusOK, response.ServerError(ctx.Tr("repo.editor.file_editing_no_longer_exists", ctx.Repo.TreePath))) + ctx.JSON(http.StatusOK, response.ServerError(ctx.Tr("repo.editor.file_or_directory_editing_no_longer_exists", ctx.Repo.TreePath))) } else if models.IsErrLFSFileLocked(err) { - ctx.JSON(http.StatusOK, response.ServerError(ctx.Tr("repo.editor.file_editing_no_longer_exists", ctx.Tr("repo.editor.upload_file_is_locked", err.(models.ErrLFSFileLocked).Path, err.(models.ErrLFSFileLocked).UserName)))) + ctx.JSON(http.StatusOK, response.ServerError(ctx.Tr("repo.editor.file_or_directory_editing_no_longer_exists", ctx.Tr("repo.editor.upload_file_is_locked", err.(models.ErrLFSFileLocked).Path, err.(models.ErrLFSFileLocked).UserName)))) } else if models.IsErrFilenameInvalid(err) { ctx.JSON(http.StatusOK, response.ServerError(ctx.Tr("repo.editor.filename_is_invalid", form.TreePath))) } else if models.IsErrFilePathInvalid(err) { From 83f9fc95b925bec1fcbc14702959e7c8ee5e68a1 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 19 May 2022 17:21:38 +0800 Subject: [PATCH 187/188] fix issue --- web_src/js/features/contexmenu.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web_src/js/features/contexmenu.js b/web_src/js/features/contexmenu.js index b357af71b..6fde05e77 100644 --- a/web_src/js/features/contexmenu.js +++ b/web_src/js/features/contexmenu.js @@ -48,6 +48,10 @@ export default async function initContextMenu() { let btn = a.currentTarget.parentNode.nextElementSibling.getElementsByTagName("button")[0] btn.addEventListener('click', function (e) { let postUrl = btn.getAttribute('data-postbasepath') + const postUrlArr = postUrl.split('/') + postUrlArr[postUrlArr.length - 1] = encodeURIComponent(postUrlArr[postUrlArr.length - 1]) + postUrl = postUrlArr.join('/') + console.log(postUrl) let last_commit = btn.getAttribute('data-commit') let tree_path = btn.getAttribute('data-treepath') + e.target.parentNode.previousElementSibling.getElementsByTagName("input")[0].value let csrf = $("input[name='_csrf']").val() From 69fc5db4d64e7ee8c8fef57a2cbceed25f0e046b Mon Sep 17 00:00:00 2001 From: Gitea Date: Thu, 19 May 2022 17:40:23 +0800 Subject: [PATCH 188/188] fix issue --- templates/repo/view_list.tmpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index 39300dcfa..747c64f12 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -131,7 +131,8 @@
- +