| @@ -82,6 +82,7 @@ type UserBusinessAnalysisQueryOptions struct { | |||||
| SortType string | SortType string | ||||
| StartTime int64 | StartTime int64 | ||||
| EndTime int64 | EndTime int64 | ||||
| IsAll bool | |||||
| } | } | ||||
| type UserBusinessAnalysisList []*UserBusinessAnalysis | type UserBusinessAnalysisList []*UserBusinessAnalysis | ||||
| @@ -142,15 +143,33 @@ func QueryUserStaticData(startTime int64, endTime int64) []*UserBusinessAnalysis | |||||
| return userBusinessAnalysisReturnList | return userBusinessAnalysisReturnList | ||||
| } | } | ||||
| func getLastCountDate() int64 { | |||||
| statictisSess := xStatistic.NewSession() | |||||
| defer statictisSess.Close() | |||||
| statictisSess.Limit(1, 0) | |||||
| userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0) | |||||
| if err := statictisSess.Table("user_business_analysis").OrderBy("count_date desc").Limit(1, 0). | |||||
| Find(&userBusinessAnalysisList); err == nil { | |||||
| for _, userRecord := range userBusinessAnalysisList { | |||||
| return userRecord.CountDate - 10000 | |||||
| } | |||||
| } else { | |||||
| log.Info("query error." + err.Error()) | |||||
| } | |||||
| currentTimeNow := time.Now() | |||||
| pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, currentTimeNow.Location()) | |||||
| return pageStartTime.Unix() | |||||
| } | |||||
| func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusinessAnalysis, int64) { | func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusinessAnalysis, int64) { | ||||
| log.Info("query startTime =" + fmt.Sprint(opts.StartTime) + " endTime=" + fmt.Sprint(opts.EndTime)) | |||||
| log.Info("query startTime =" + fmt.Sprint(opts.StartTime) + " endTime=" + fmt.Sprint(opts.EndTime) + " isAll=" + fmt.Sprint(opts.IsAll)) | |||||
| statictisSess := xStatistic.NewSession() | statictisSess := xStatistic.NewSession() | ||||
| defer statictisSess.Close() | defer statictisSess.Close() | ||||
| currentTimeNow := time.Now() | currentTimeNow := time.Now() | ||||
| pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, currentTimeNow.Location()) | |||||
| pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) | |||||
| pageStartTime := getLastCountDate() | |||||
| pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()).Unix() | |||||
| var cond = builder.NewCond() | var cond = builder.NewCond() | ||||
| if len(opts.UserName) > 0 { | if len(opts.UserName) > 0 { | ||||
| @@ -159,10 +178,10 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus | |||||
| ) | ) | ||||
| } | } | ||||
| cond = cond.And( | cond = cond.And( | ||||
| builder.Gte{"count_date": pageStartTime.Unix()}, | |||||
| builder.Gte{"count_date": pageStartTime}, | |||||
| ) | ) | ||||
| cond = cond.And( | cond = cond.And( | ||||
| builder.Lte{"count_date": pageEndTime.Unix()}, | |||||
| builder.Lte{"count_date": pageEndTime}, | |||||
| ) | ) | ||||
| count, err := statictisSess.Where(cond).Count(new(UserBusinessAnalysis)) | count, err := statictisSess.Where(cond).Count(new(UserBusinessAnalysis)) | ||||
| @@ -190,7 +209,7 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus | |||||
| resultMap := make(map[int64]*UserBusinessAnalysis) | resultMap := make(map[int64]*UserBusinessAnalysis) | ||||
| if opts.Page >= 0 && opts.PageSize > 0 { | |||||
| if opts.Page >= 0 && opts.PageSize > 0 && len(userBusinessAnalysisList) > 0 { | |||||
| var newAndCond = builder.NewCond() | var newAndCond = builder.NewCond() | ||||
| var newOrCond = builder.NewCond() | var newOrCond = builder.NewCond() | ||||
| for _, userRecord := range userBusinessAnalysisList { | for _, userRecord := range userBusinessAnalysisList { | ||||
| @@ -201,12 +220,14 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus | |||||
| newAndCond = newAndCond.And( | newAndCond = newAndCond.And( | ||||
| newOrCond, | newOrCond, | ||||
| ) | ) | ||||
| newAndCond = newAndCond.And( | |||||
| builder.Gte{"count_date": opts.StartTime}, | |||||
| ) | |||||
| newAndCond = newAndCond.And( | |||||
| builder.Lte{"count_date": opts.EndTime}, | |||||
| ) | |||||
| if !opts.IsAll { | |||||
| newAndCond = newAndCond.And( | |||||
| builder.Gte{"count_date": opts.StartTime}, | |||||
| ) | |||||
| newAndCond = newAndCond.And( | |||||
| builder.Lte{"count_date": opts.EndTime}, | |||||
| ) | |||||
| } | |||||
| userBusinessAnalysisList = make([]*UserBusinessAnalysis, 0) | userBusinessAnalysisList = make([]*UserBusinessAnalysis, 0) | ||||
| if err := statictisSess.Table("user_business_analysis").Where(newAndCond). | if err := statictisSess.Table("user_business_analysis").Where(newAndCond). | ||||
| @@ -246,7 +267,7 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus | |||||
| return userBusinessAnalysisReturnList, count | return userBusinessAnalysisReturnList, count | ||||
| } | } | ||||
| func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, endTime time.Time, isReCount bool) { | |||||
| func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, endTime time.Time, isReCount bool) error { | |||||
| log.Info("start to count other user info data") | log.Info("start to count other user info data") | ||||
| sess := x.NewSession() | sess := x.NewSession() | ||||
| @@ -394,9 +415,13 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, | |||||
| dateRecord.CommitModelCount = 0 | dateRecord.CommitModelCount = 0 | ||||
| statictisSess.Insert(&dateRecord) | |||||
| _, err = statictisSess.Insert(&dateRecord) | |||||
| if err != nil { | |||||
| log.Info("insert daterecord failed." + err.Error()) | |||||
| return err | |||||
| } | |||||
| } | } | ||||
| return nil | |||||
| } | } | ||||
| func CounDataByDate(wikiCountMap map[string]int, startTime time.Time, endTime time.Time) { | func CounDataByDate(wikiCountMap map[string]int, startTime time.Time, endTime time.Time) { | ||||
| @@ -32,7 +32,7 @@ func (repo *Repository) GetMergeBase(tmpRemote string, base, head string) (strin | |||||
| if tmpRemote != "origin" { | if tmpRemote != "origin" { | ||||
| tmpBaseName := "refs/remotes/" + tmpRemote + "/tmp_" + base | tmpBaseName := "refs/remotes/" + tmpRemote + "/tmp_" + base | ||||
| // Fetch commit into a temporary branch in order to be able to handle commits and tags | // Fetch commit into a temporary branch in order to be able to handle commits and tags | ||||
| _, err := NewCommand("fetch", tmpRemote, base+":"+tmpBaseName).RunInDir(repo.Path) | |||||
| _, err := NewCommand("fetch", tmpRemote, base+":"+tmpBaseName,"--no-tags").RunInDir(repo.Path) | |||||
| if err == nil { | if err == nil { | ||||
| base = tmpBaseName | base = tmpBaseName | ||||
| } | } | ||||
| @@ -29,20 +29,20 @@ type FileInfo struct { | |||||
| } | } | ||||
| //check if has the object | //check if has the object | ||||
| //todo:修改查询方式 | |||||
| func ObsHasObject(path string) (bool, error) { | func ObsHasObject(path string) (bool, error) { | ||||
| hasObject := false | hasObject := false | ||||
| output, err := ObsCli.ListObjects(&obs.ListObjectsInput{Bucket: setting.Bucket}) | |||||
| if err != nil { | |||||
| log.Error("ListObjects failed:%v", err) | |||||
| return hasObject, err | |||||
| } | |||||
| for _, obj := range output.Contents { | |||||
| //obj.Key:attachment/0/1/019fd24e-4ef7-41cc-9f85-4a7b8504d958 | |||||
| if path == obj.Key { | |||||
| hasObject = true | |||||
| break | |||||
| input := &obs.GetObjectMetadataInput{} | |||||
| input.Bucket = setting.Bucket | |||||
| input.Key = path | |||||
| _, err := ObsCli.GetObjectMetadata(input) | |||||
| if err == nil { | |||||
| hasObject = true | |||||
| } else { | |||||
| if obsError, ok := err.(obs.ObsError); ok { | |||||
| log.Error("GetObjectMetadata failed(%d): %s", obsError.StatusCode, obsError.Message) | |||||
| } else { | |||||
| log.Error("%v", err.Error()) | |||||
| } | } | ||||
| } | } | ||||
| @@ -420,7 +420,7 @@ static.createrepocount=Create Repo Count | |||||
| static.openiindex=OpenI Index | static.openiindex=OpenI Index | ||||
| static.registdate=Regist Date | static.registdate=Regist Date | ||||
| static.countdate=Count Date | static.countdate=Count Date | ||||
| static.all=All | |||||
| [settings] | [settings] | ||||
| profile = Profile | profile = Profile | ||||
| @@ -815,7 +815,7 @@ get_repo_stat_error=Can not get the statistics of the repository. | |||||
| get_repo_info_error=Can not get the information of the repository. | get_repo_info_error=Can not get the information of the repository. | ||||
| generate_statistic_file_error=Fail to generate file. | generate_statistic_file_error=Fail to generate file. | ||||
| repo_stat_inspect=ProjectAnalysis | repo_stat_inspect=ProjectAnalysis | ||||
| all=all | |||||
| all=All | |||||
| modelarts.notebook=Debug Task | modelarts.notebook=Debug Task | ||||
| modelarts.train_job=Train Task | modelarts.train_job=Train Task | ||||
| modelarts.train_job.new_debug= New Debug Task | modelarts.train_job.new_debug= New Debug Task | ||||
| @@ -423,6 +423,7 @@ static.createrepocount=创建项目数 | |||||
| static.openiindex=OpenI指数 | static.openiindex=OpenI指数 | ||||
| static.registdate=用户注册时间 | static.registdate=用户注册时间 | ||||
| static.countdate=系统统计时间 | static.countdate=系统统计时间 | ||||
| static.all=所有 | |||||
| [settings] | [settings] | ||||
| profile=个人信息 | profile=个人信息 | ||||
| account=账号 | account=账号 | ||||
| @@ -360,6 +360,7 @@ func GetPresignedPutObjectURL(ctx *context.Context) { | |||||
| // AddAttachment response for add attachment record | // AddAttachment response for add attachment record | ||||
| func AddAttachment(ctx *context.Context) { | func AddAttachment(ctx *context.Context) { | ||||
| typeCloudBrain := ctx.QueryInt("type") | typeCloudBrain := ctx.QueryInt("type") | ||||
| fileName := ctx.Query("file_name") | |||||
| err := checkTypeCloudBrain(typeCloudBrain) | err := checkTypeCloudBrain(typeCloudBrain) | ||||
| if err != nil { | if err != nil { | ||||
| ctx.ServerError("checkTypeCloudBrain failed", err) | ctx.ServerError("checkTypeCloudBrain failed", err) | ||||
| @@ -375,7 +376,7 @@ func AddAttachment(ctx *context.Context) { | |||||
| return | return | ||||
| } | } | ||||
| } else { | } else { | ||||
| has, err = storage.ObsHasObject(setting.BasePath + models.AttachmentRelativePath(uuid) + "/" + uuid) | |||||
| has, err = storage.ObsHasObject(setting.BasePath + models.AttachmentRelativePath(uuid) + "/" + fileName) | |||||
| if err != nil { | if err != nil { | ||||
| ctx.ServerError("ObsHasObject", err) | ctx.ServerError("ObsHasObject", err) | ||||
| return | return | ||||
| @@ -391,7 +392,7 @@ func AddAttachment(ctx *context.Context) { | |||||
| UUID: uuid, | UUID: uuid, | ||||
| UploaderID: ctx.User.ID, | UploaderID: ctx.User.ID, | ||||
| IsPrivate: true, | IsPrivate: true, | ||||
| Name: ctx.Query("file_name"), | |||||
| Name: fileName, | |||||
| Size: ctx.QueryInt64("size"), | Size: ctx.QueryInt64("size"), | ||||
| DatasetID: ctx.QueryInt64("dataset_id"), | DatasetID: ctx.QueryInt64("dataset_id"), | ||||
| Type: typeCloudBrain, | Type: typeCloudBrain, | ||||
| @@ -479,6 +480,7 @@ func UpdateAttachmentDecompressState(ctx *context.Context) { | |||||
| func GetSuccessChunks(ctx *context.Context) { | func GetSuccessChunks(ctx *context.Context) { | ||||
| fileMD5 := ctx.Query("md5") | fileMD5 := ctx.Query("md5") | ||||
| typeCloudBrain := ctx.QueryInt("type") | typeCloudBrain := ctx.QueryInt("type") | ||||
| fileName := ctx.Query("file_name") | |||||
| var chunks string | var chunks string | ||||
| err := checkTypeCloudBrain(typeCloudBrain) | err := checkTypeCloudBrain(typeCloudBrain) | ||||
| @@ -510,7 +512,7 @@ func GetSuccessChunks(ctx *context.Context) { | |||||
| return | return | ||||
| } | } | ||||
| } else { | } else { | ||||
| isExist, err = storage.ObsHasObject(setting.BasePath + models.AttachmentRelativePath(fileChunk.UUID) + "/" + fileChunk.UUID) | |||||
| isExist, err = storage.ObsHasObject(setting.BasePath + models.AttachmentRelativePath(fileChunk.UUID) + "/" + fileName) | |||||
| if err != nil { | if err != nil { | ||||
| ctx.ServerError("ObsHasObject failed", err) | ctx.ServerError("ObsHasObject failed", err) | ||||
| return | return | ||||
| @@ -12,6 +12,7 @@ import ( | |||||
| "code.gitea.io/gitea/modules/git" | "code.gitea.io/gitea/modules/git" | ||||
| "code.gitea.io/gitea/modules/log" | "code.gitea.io/gitea/modules/log" | ||||
| "code.gitea.io/gitea/modules/setting" | "code.gitea.io/gitea/modules/setting" | ||||
| "code.gitea.io/gitea/services/mailer" | |||||
| "github.com/360EntSecGroup-Skylar/excelize/v2" | "github.com/360EntSecGroup-Skylar/excelize/v2" | ||||
| ) | ) | ||||
| @@ -39,12 +40,26 @@ func QueryUserStaticDataPage(ctx *context.Context) { | |||||
| } | } | ||||
| userName := ctx.Query("userName") | userName := ctx.Query("userName") | ||||
| IsReturnFile := ctx.QueryBool("IsReturnFile") | IsReturnFile := ctx.QueryBool("IsReturnFile") | ||||
| log.Info("startDate=" + startDate + " endDate=" + endDate + " userName=" + userName + " page=" + fmt.Sprint(page)) | log.Info("startDate=" + startDate + " endDate=" + endDate + " userName=" + userName + " page=" + fmt.Sprint(page)) | ||||
| startTime, _ := time.Parse("2006-01-02", startDate) | |||||
| endTime, _ := time.Parse("2006-01-02", endDate) | |||||
| endTime = endTime.AddDate(0, 0, 1) | |||||
| log.Info("startTime=" + fmt.Sprint(startTime.Unix()) + " endDate=" + fmt.Sprint(endTime.Unix())) | |||||
| var startTime time.Time | |||||
| var endTime time.Time | |||||
| var isAll bool | |||||
| if startDate == "all" { | |||||
| isAll = true | |||||
| startTime = time.Now() | |||||
| endTime = time.Now() | |||||
| } else { | |||||
| startTime, _ = time.Parse("2006-01-02", startDate) | |||||
| settingStartTime, _ := time.Parse("2006-01-02", setting.RadarMap.RecordBeginTime) | |||||
| if startTime.Unix() < settingStartTime.Unix() { | |||||
| startTime = settingStartTime | |||||
| startDate = settingStartTime.Format("2006-01-02") | |||||
| } | |||||
| endTime, _ = time.Parse("2006-01-02", endDate) | |||||
| endTime = endTime.AddDate(0, 0, 1) | |||||
| isAll = false | |||||
| log.Info("startTime=" + fmt.Sprint(startTime.Unix()) + " endDate=" + fmt.Sprint(endTime.Unix())) | |||||
| } | |||||
| if IsReturnFile { | if IsReturnFile { | ||||
| page = -1 | page = -1 | ||||
| @@ -59,6 +74,7 @@ func QueryUserStaticDataPage(ctx *context.Context) { | |||||
| UserName: userName, | UserName: userName, | ||||
| StartTime: startTime.Unix(), | StartTime: startTime.Unix(), | ||||
| EndTime: endTime.Unix(), | EndTime: endTime.Unix(), | ||||
| IsAll: isAll, | |||||
| } | } | ||||
| mapInterface := make(map[string]interface{}) | mapInterface := make(map[string]interface{}) | ||||
| re, count := models.QueryUserStaticDataPage(pageOpts) | re, count := models.QueryUserStaticDataPage(pageOpts) | ||||
| @@ -67,8 +83,10 @@ func QueryUserStaticDataPage(ctx *context.Context) { | |||||
| if IsReturnFile { | if IsReturnFile { | ||||
| //writer exec file. | //writer exec file. | ||||
| xlsx := excelize.NewFile() | xlsx := excelize.NewFile() | ||||
| xlsx.DeleteSheet("Sheet1") | |||||
| sheetName := ctx.Tr("user.static.sheetname") | sheetName := ctx.Tr("user.static.sheetname") | ||||
| index := xlsx.NewSheet(sheetName) | index := xlsx.NewSheet(sheetName) | ||||
| dataHeader := map[string]string{ | dataHeader := map[string]string{ | ||||
| "A1": ctx.Tr("user.static.id"), | "A1": ctx.Tr("user.static.id"), | ||||
| "B1": ctx.Tr("user.static.name"), | "B1": ctx.Tr("user.static.name"), | ||||
| @@ -110,14 +128,27 @@ func QueryUserStaticDataPage(ctx *context.Context) { | |||||
| xlsx.SetCellValue(sheetName, "L"+rows, userRecord.SolveIssueCount) | xlsx.SetCellValue(sheetName, "L"+rows, userRecord.SolveIssueCount) | ||||
| xlsx.SetCellValue(sheetName, "M"+rows, userRecord.EncyclopediasCount) | xlsx.SetCellValue(sheetName, "M"+rows, userRecord.EncyclopediasCount) | ||||
| xlsx.SetCellValue(sheetName, "N"+rows, userRecord.CreateRepoCount) | xlsx.SetCellValue(sheetName, "N"+rows, userRecord.CreateRepoCount) | ||||
| xlsx.SetCellValue(sheetName, "O"+rows, userRecord.OpenIIndex) | |||||
| xlsx.SetCellValue(sheetName, "O"+rows, fmt.Sprintf("%.2f", userRecord.OpenIIndex)) | |||||
| xlsx.SetCellValue(sheetName, "P"+rows, userRecord.RegistDate.Format("2006-01-02")) | xlsx.SetCellValue(sheetName, "P"+rows, userRecord.RegistDate.Format("2006-01-02")) | ||||
| xlsx.SetCellValue(sheetName, "Q"+rows, time.Unix(userRecord.CountDate, 0).Format("2006-01-02")) | xlsx.SetCellValue(sheetName, "Q"+rows, time.Unix(userRecord.CountDate, 0).Format("2006-01-02")) | ||||
| } | } | ||||
| //设置默认打开的表单 | //设置默认打开的表单 | ||||
| xlsx.SetActiveSheet(index) | xlsx.SetActiveSheet(index) | ||||
| filename := sheetName + "_" + strings.ReplaceAll(startDate, "-", "") + "_" + strings.ReplaceAll(endDate, "-", "") + ".xlsx" | |||||
| var filename string | |||||
| nowTime := time.Now() | |||||
| nowZeroTime := time.Date(nowTime.Year(), nowTime.Month(), nowTime.Day(), 0, 0, 0, 0, nowTime.Location()) | |||||
| if endTime.Unix() >= nowZeroTime.Unix() { | |||||
| endDate = nowZeroTime.AddDate(0, 0, -1).Format("2006-01-02") | |||||
| } | |||||
| if isAll { | |||||
| filename = sheetName + "_" + ctx.Tr("user.static.all") + ".xlsx" | |||||
| } else { | |||||
| filename = sheetName + "_" + strings.ReplaceAll(startDate, "-", "") + "_" + strings.ReplaceAll(endDate, "-", "") + ".xlsx" | |||||
| } | |||||
| if len(userName) > 0 { | if len(userName) > 0 { | ||||
| filename = sheetName + "_" + userName + "_" + strings.ReplaceAll(startDate, "-", "") + "_" + strings.ReplaceAll(endDate, "-", "") + ".xlsx" | filename = sheetName + "_" + userName + "_" + strings.ReplaceAll(startDate, "-", "") + "_" + strings.ReplaceAll(endDate, "-", "") + ".xlsx" | ||||
| } | } | ||||
| @@ -142,10 +173,11 @@ func TimingCountDataByDateAndReCount(date string, isReCount bool) { | |||||
| //query wiki data | //query wiki data | ||||
| log.Info("start to time count data") | log.Info("start to time count data") | ||||
| wikiMap := make(map[string]int) | wikiMap := make(map[string]int) | ||||
| warnEmailMessage := "用户统计信息入库失败,请尽快定位。" | |||||
| repoList, err := models.GetAllRepositories() | repoList, err := models.GetAllRepositories() | ||||
| if err != nil { | if err != nil { | ||||
| log.Error("query repo error.") | |||||
| log.Error("query repo error." + err.Error()) | |||||
| mailer.SendWarnNotifyMail(setting.Warn_Notify_Mails, warnEmailMessage) | |||||
| return | return | ||||
| } | } | ||||
| log.Info("start to query wiki data") | log.Info("start to query wiki data") | ||||
| @@ -180,7 +212,11 @@ func TimingCountDataByDateAndReCount(date string, isReCount bool) { | |||||
| } | } | ||||
| } | } | ||||
| //other user info data | //other user info data | ||||
| models.CounDataByDateAndReCount(wikiMap, startTime, endTime, isReCount) | |||||
| err = models.CounDataByDateAndReCount(wikiMap, startTime, endTime, isReCount) | |||||
| if err != nil { | |||||
| log.Error("count user info error." + err.Error()) | |||||
| mailer.SendWarnNotifyMail(setting.Warn_Notify_Mails, warnEmailMessage) | |||||
| } | |||||
| } | } | ||||
| func TimingCountDataByDate(date string) { | func TimingCountDataByDate(date string) { | ||||
| @@ -824,24 +824,21 @@ func renderCode(ctx *context.Context) { | |||||
| */ | */ | ||||
| baseGitRepo, err := git.OpenRepository(ctx.Repo.Repository.BaseRepo.RepoPath()) | baseGitRepo, err := git.OpenRepository(ctx.Repo.Repository.BaseRepo.RepoPath()) | ||||
| defer baseGitRepo.Close() | defer baseGitRepo.Close() | ||||
| var compareInfo *git.CompareInfo | |||||
| if err != nil { | if err != nil { | ||||
| log.Error("error open baseRepo:%s", ctx.Repo.Repository.BaseRepo.RepoPath()) | log.Error("error open baseRepo:%s", ctx.Repo.Repository.BaseRepo.RepoPath()) | ||||
| ctx.Data["FetchUpstreamCnt"] = -1 // minus value indicates error | ctx.Data["FetchUpstreamCnt"] = -1 // minus value indicates error | ||||
| } else { | } else { | ||||
| if _, error := baseGitRepo.GetBranch(ctx.Repo.BranchName); error == nil { | if _, error := baseGitRepo.GetBranch(ctx.Repo.BranchName); error == nil { | ||||
| //base repo has the same branch, then compare between current repo branch and base repo's branch | //base repo has the same branch, then compare between current repo branch and base repo's branch | ||||
| compareUrl := ctx.Repo.BranchName + "..." + ctx.Repo.Repository.BaseRepo.OwnerName + "/" + ctx.Repo.Repository.BaseRepo.Name + ":" + ctx.Repo.BranchName | |||||
| ctx.SetParams("*", compareUrl) | |||||
| compareInfo, err = baseGitRepo.GetCompareInfo(ctx.Repo.Repository.RepoPath(), ctx.Repo.BranchName, ctx.Repo.BranchName) | |||||
| ctx.Data["UpstreamSameBranchName"] = true | ctx.Data["UpstreamSameBranchName"] = true | ||||
| } else { | } else { | ||||
| //else, compare between current repo branch and base repo's default branch | //else, compare between current repo branch and base repo's default branch | ||||
| compareUrl := ctx.Repo.BranchName + "..." + ctx.Repo.Repository.BaseRepo.OwnerName + "/" + ctx.Repo.Repository.BaseRepo.Name + ":" + ctx.Repo.Repository.BaseRepo.DefaultBranch | |||||
| ctx.SetParams("*", compareUrl) | |||||
| compareInfo, err = baseGitRepo.GetCompareInfo(ctx.Repo.Repository.RepoPath(), ctx.Repo.BranchName, ctx.Repo.Repository.BaseRepo.DefaultBranch) | |||||
| ctx.Data["UpstreamSameBranchName"] = false | ctx.Data["UpstreamSameBranchName"] = false | ||||
| } | } | ||||
| _, _, headGitRepo, compareInfo, _, _ := ParseCompareInfo(ctx) | |||||
| defer headGitRepo.Close() | |||||
| if compareInfo != nil { | |||||
| if err==nil && compareInfo != nil { | |||||
| if compareInfo.Commits != nil { | if compareInfo.Commits != nil { | ||||
| log.Info("compareInfoCommits数量:%d", compareInfo.Commits.Len()) | log.Info("compareInfoCommits数量:%d", compareInfo.Commits.Len()) | ||||
| ctx.Data["FetchUpstreamCnt"] = compareInfo.Commits.Len() | ctx.Data["FetchUpstreamCnt"] = compareInfo.Commits.Len() | ||||
| @@ -20,7 +20,7 @@ | |||||
| 项目分析 | 项目分析 | ||||
| </span> | </span> | ||||
| </el-tab-pane> | </el-tab-pane> | ||||
| <el-tab-pane name="third" > | |||||
| <el-tab-pane name="third" id='third'> | |||||
| <span slot='label'> | <span slot='label'> | ||||
| <el-image style="width: 13px; height: 13px" src="/img/name.png"> | <el-image style="width: 13px; height: 13px" src="/img/name.png"> | ||||
| </el-image> | </el-image> | ||||
| @@ -69,18 +69,22 @@ | |||||
| if(tab.name=="third"){ | if(tab.name=="third"){ | ||||
| // document.getElementById('usr').style.display="block" | // document.getElementById('usr').style.display="block" | ||||
| // document.getElementById("pro").style.display='none' | // document.getElementById("pro").style.display='none' | ||||
| this.$refs.UserAnalysis.getUserList("all_usr",7) | |||||
| this.reload() | |||||
| this.isSecond = false | this.isSecond = false | ||||
| this.isThird = true | this.isThird = true | ||||
| this.$refs.UserAnalysis.resetPage() | |||||
| this.$refs.UserAnalysis.getUpdateTime() | |||||
| this.$refs.UserAnalysis.getUserList("all_usr",7) | |||||
| } | } | ||||
| }, | |||||
| }, | |||||
| reload () { | |||||
| this.isRouterAlive = false | |||||
| this.$nextTick(() => (this.isRouterAlive = true)) | |||||
| } | |||||
| reload () { | |||||
| this.isRouterAlive = false | |||||
| this.$nextTick(() => (this.isRouterAlive = true)) | |||||
| } | |||||
| }, | }, | ||||
| } | } | ||||
| @@ -262,6 +262,7 @@ export default { | |||||
| params: { | params: { | ||||
| md5: file.uniqueIdentifier, | md5: file.uniqueIdentifier, | ||||
| type: CloudBrainType, | type: CloudBrainType, | ||||
| file_name: file.name, | |||||
| _csrf: csrf | _csrf: csrf | ||||
| } | } | ||||
| }; | }; | ||||
| @@ -53,16 +53,6 @@ | |||||
| stripe | stripe | ||||
| > | > | ||||
| </el-table-column> | </el-table-column> | ||||
| <el-table-column | |||||
| label="拥有者" | |||||
| align="center" | |||||
| prop="ownerName" | |||||
| stripe | |||||
| v-if='0' | |||||
| > | |||||
| </el-table-column> | |||||
| <el-table-column | <el-table-column | ||||
| label="项目名称" | label="项目名称" | ||||
| width="125px" | width="125px" | ||||
| @@ -73,6 +63,13 @@ | |||||
| <template slot-scope="scope"> | <template slot-scope="scope"> | ||||
| <a @click=goToDetailPage(scope.row.repo_id,scope.row.name,scope.row.ownerName)>{{scope.row.name}} </a> | <a @click=goToDetailPage(scope.row.repo_id,scope.row.name,scope.row.ownerName)>{{scope.row.name}} </a> | ||||
| </template> | </template> | ||||
| </el-table-column> | |||||
| <el-table-column | |||||
| label="拥有者" | |||||
| align="center" | |||||
| prop="ownerName" | |||||
| stripe | |||||
| > | |||||
| </el-table-column> | </el-table-column> | ||||
| <el-table-column | <el-table-column | ||||
| prop="isPrivate" | prop="isPrivate" | ||||
| @@ -156,7 +153,7 @@ | |||||
| </div> | </div> | ||||
| <div id ="pro_detail" style="display:none;width: 100%;"> | <div id ="pro_detail" style="display:none;width: 100%;"> | ||||
| <div style="margin-top: 10px;"> | <div style="margin-top: 10px;"> | ||||
| <b class="pro_item">{{this.ownerName}}/{{this.pro_name}}</b> <span class="update_time">数据更新时间:</span><span style="font-size: 12px;">{{tableDataIDTotal.lastUpdatedTime}}/{{tableDataIDTotal.recordBeginTime}}</span> | |||||
| <b class="pro_item">{{this.ownerName}} / {{this.pro_name}}</b> <span class="update_time">数据更新时间:</span><span style="font-size: 12px;">{{tableDataIDTotal.lastUpdatedTime}} / 从{{tableDataIDTotal.recordBeginTime}}开始</span> | |||||
| </div> | </div> | ||||
| <div style="margin-top: 10px;"> | <div style="margin-top: 10px;"> | ||||
| 项目描述:{{tableDataIDTotal.description | discriptionFun}} | 项目描述:{{tableDataIDTotal.description | discriptionFun}} | ||||
| @@ -185,7 +182,7 @@ | |||||
| </el-col> | </el-col> | ||||
| <el-col :span='4' style="text-align: center;"> | <el-col :span='4' style="text-align: center;"> | ||||
| <el-row>任务完成比例</el-row> | <el-row>任务完成比例</el-row> | ||||
| <el-row class="item_content">{{tableDataIDTotal.issueClosedRatio * 100}}%</el-row> | |||||
| <el-row class="item_content">{{Math.round(tableDataIDTotal.issueClosedRatio * 100) }}%</el-row> | |||||
| </el-col> | </el-col> | ||||
| </el-row> | </el-row> | ||||
| </div> | </div> | ||||
| @@ -248,18 +245,18 @@ | |||||
| </div> | </div> | ||||
| <div style="margin-top: 20px;"> | <div style="margin-top: 20px;"> | ||||
| <span class="sta_iterm">统计周期:</span> | <span class="sta_iterm">统计周期:</span> | ||||
| <button type="button" class='btn' id ="yesterday_pro" v-bind:class="{colorChange:1==dynamic_pro}" @click="resetCurrentPage(),getOneProList(pro_id,'yesterday',true,1),getOneProList(pro_id,'yesterday',false,1)">昨天</button> | |||||
| <button type="button" class='btn' id = "current_week_pro" v-bind:class="{colorChange:2==dynamic_pro}" @click="resetCurrentPage(),getOneProList(pro_id,'current_week',true,2),getOneProList(pro_id,'current_week',false,2)">本周</button> | |||||
| <button type="button" class='btn' id = "current_month_pro" v-bind:class="{colorChange:3==dynamic_pro}" @click="resetCurrentPage(),getOneProList(pro_id,'current_month',true,3),getOneProList(pro_id,'current_month',false,3)">本月</button> | |||||
| <button type="button" class='btn' id = "last_month_pro" v-bind:class="{colorChange:4==dynamic_pro}" @click="resetCurrentPage(),getOneProList(pro_id,'last_month',true,4),getOneProList(pro_id,'last_month',false,4)">上月</button> | |||||
| <button type="button" class='btn' id = "monthly_pro" v-bind:class="{colorChange:5==dynamic_pro}" @click="resetCurrentPage(),getOneProList(pro_id,'monthly',true,5),getOneProList(pro_id,'monthly',false,5)">近30天</button> | |||||
| <button type="button" class='btn' id = "current_year_pro" v-bind:class="{colorChange:6==dynamic}" @click="resetCurrentPage(),getOneProList(pro_id,'current_year',true,6),getOneProList(pro_id,'current_year',false,6)">今年</button> | |||||
| <button type="button" class='btn' id = "all_pro" v-bind:class="{colorChange:7==dynamic_pro}" @click="resetCurrentPage(),getOneProList(pro_id,'all',true,7),getOneProList(pro_id,'all',false,7)">所有</button> | |||||
| <button type="button" class='btn' id ="yesterday_pro" v-bind:class="{colorChange:1==dynamic_pro}" @click="resetCurrentPage(),getOneProList(pro_id,'yesterday',false,1)">昨天</button> | |||||
| <button type="button" class='btn' id = "current_week_pro" v-bind:class="{colorChange:2==dynamic_pro}" @click="resetCurrentPage(),getOneProList(pro_id,'current_week',false,2)">本周</button> | |||||
| <button type="button" class='btn' id = "current_month_pro" v-bind:class="{colorChange:3==dynamic_pro}" @click="resetCurrentPage(),getOneProList(pro_id,'current_month',false,3)">本月</button> | |||||
| <button type="button" class='btn' id = "last_month_pro" v-bind:class="{colorChange:4==dynamic_pro}" @click="resetCurrentPage(),getOneProList(pro_id,'last_month',false,4)">上月</button> | |||||
| <button type="button" class='btn' id = "monthly_pro" v-bind:class="{colorChange:5==dynamic_pro}" @click="resetCurrentPage(),getOneProList(pro_id,'monthly',false,5)">近30天</button> | |||||
| <button type="button" class='btn' id = "current_year_pro" v-bind:class="{colorChange:6==dynamic_pro}" @click="resetCurrentPage(),getOneProList(pro_id,'current_year',false,6)">今年</button> | |||||
| <button type="button" class='btn' id = "all_pro" v-bind:class="{colorChange:7==dynamic_pro}" @click="resetCurrentPage(),getOneProList(pro_id,'all',false,7)">所有</button> | |||||
| <span style="margin-left: 20px;"> | <span style="margin-left: 20px;"> | ||||
| <el-date-picker | <el-date-picker | ||||
| v-model="create_time_pro" | v-model="create_time_pro" | ||||
| prefix-icon="el-icon-time" | prefix-icon="el-icon-time" | ||||
| @change="resetCurrentPage(),getOneProList(pro_id,'',true,0),getOneProList(pro_id,'',false,0),clickCheckBox" | |||||
| @change="resetCurrentPage(),getOneProList(pro_id,'',false,0),clickCheckBox" | |||||
| type="daterange" | type="daterange" | ||||
| size='small' | size='small' | ||||
| range-separator="至" | range-separator="至" | ||||
| @@ -405,6 +402,9 @@ | |||||
| var nowMonth = now.getMonth(); // 当前月 | var nowMonth = now.getMonth(); // 当前月 | ||||
| var nowYear = now.getFullYear(); // 当前年 | var nowYear = now.getFullYear(); // 当前年 | ||||
| var today = this.saveFormatDate(nowYear,nowMonth+1,nowDay); | var today = this.saveFormatDate(nowYear,nowMonth+1,nowDay); | ||||
| var tmp = new Date(now.setTime(now.getTime()-24*60*60*1000)); | |||||
| var yesterday = this.saveFormatDate(tmp.getFullYear(),tmp.getMonth()+1,tmp.getDate()); | |||||
| var yesterday_tmp = this.formatDate(tmp.getFullYear(),tmp.getMonth()+1,tmp.getDate()) | |||||
| let lastMonthDate = new Date(); // 上月日期 | let lastMonthDate = new Date(); // 上月日期 | ||||
| lastMonthDate.setDate(1); | lastMonthDate.setDate(1); | ||||
| @@ -416,16 +416,22 @@ | |||||
| var saveFileName = '' | var saveFileName = '' | ||||
| if (typeof this.paramsID.type=="undefined" || this.paramsID.type=="null" || this.paramsID.type==""){ | if (typeof this.paramsID.type=="undefined" || this.paramsID.type=="null" || this.paramsID.type==""){ | ||||
| startDate= this.saveFormatDate(this.create_time_pro[0].getFullYear(),this.create_time_pro[0].getMonth() + 1,this.create_time_pro[0].getDate()); | |||||
| // startDate= this.saveFormatDate(this.create_time_pro[0].getFullYear(),this.create_time_pro[0].getMonth() + 1,this.create_time_pro[0].getDate()); | |||||
| endDate = this.saveFormatDate(this.create_time_pro[1].getFullYear(),this.create_time_pro[1].getMonth() + 1,this.create_time_pro[1].getDate()); | endDate = this.saveFormatDate(this.create_time_pro[1].getFullYear(),this.create_time_pro[1].getMonth() + 1,this.create_time_pro[1].getDate()); | ||||
| var tmp = this.formatDate(this.create_time_pro[0].getFullYear(),this.create_time_pro[0].getMonth() + 1,this.create_time_pro[0].getDate()) | |||||
| startDate = this.comparedate(tmp,this.recordBeginTime) | |||||
| console.log("comparedate:"+startDate) | |||||
| saveFileName = this.pro_name+"_"+startDate+'_'+endDate | saveFileName = this.pro_name+"_"+startDate+'_'+endDate | ||||
| }else{ | }else{ | ||||
| switch(this.paramsID.type){ | switch(this.paramsID.type){ | ||||
| case "yesterday":{ | case "yesterday":{ | ||||
| var now = new Date(); | |||||
| var tmp = new Date(now.setTime(now.getTime()-24*60*60*1000)); | |||||
| startDate = this.saveFormatDate(tmp.getFullYear(),tmp.getMonth()+1,tmp.getDate()); | |||||
| endDate = today | |||||
| startDate = this.comparedate(yesterday_tmp,this.recordBeginTime) | |||||
| endDate = startDate | |||||
| saveFileName = this.pro_name+"_"+startDate+'_'+ endDate | saveFileName = this.pro_name+"_"+startDate+'_'+ endDate | ||||
| break | break | ||||
| } | } | ||||
| @@ -433,43 +439,54 @@ | |||||
| var now = new Date(); // 当前日期 | var now = new Date(); // 当前日期 | ||||
| var nowDayOfWeek = now.getDay(); // 今天本周的第几天 | var nowDayOfWeek = now.getDay(); // 今天本周的第几天 | ||||
| var day = nowDayOfWeek || 7; | var day = nowDayOfWeek || 7; | ||||
| startDate = this.saveFormatDate(now.getFullYear(), nowMonth+1, nowDay + 1 - day); | |||||
| endDate = today | |||||
| startDate = this.formatDate(now.getFullYear(), nowMonth+1, nowDay + 1 - day); | |||||
| startDate = this.comparedate(startDate,this.recordBeginTime) | |||||
| endDate = yesterday | |||||
| saveFileName = this.pro_name+"_"+startDate+'_'+ endDate | saveFileName = this.pro_name+"_"+startDate+'_'+ endDate | ||||
| break | break | ||||
| } | } | ||||
| case "current_month":{ | case "current_month":{ | ||||
| startDate = this.saveFormatDate(nowYear,nowMonth+1,1); | |||||
| endDate = today | |||||
| startDate = this.formatDate(nowYear,nowMonth+1,1); | |||||
| startDate = this.comparedate(startDate,this.recordBeginTime) | |||||
| endDate = yesterday | |||||
| saveFileName = this.pro_name+"_"+startDate+'_'+ endDate | saveFileName = this.pro_name+"_"+startDate+'_'+ endDate | ||||
| break | break | ||||
| } | } | ||||
| case "last_month":{ | case "last_month":{ | ||||
| startDate=this.saveFormatDate(nowYear, lastMonth+1, 1); | |||||
| endDate=this.saveFormatDate(nowYear, lastMonth+1, this.saveFormatDate(nowYear,lastMonth)); | |||||
| endDate = today | |||||
| startDate=this.formatDate(nowYear, lastMonth+1, 1); | |||||
| startDate = this.comparedate(startDate,this.recordBeginTime) | |||||
| endDate=this.saveFormatDate(nowYear, lastMonth+1, this.saveFormatDate(nowYear,lastMonth)); | |||||
| saveFileName = this.pro_name+"_"+startDate+'_'+ endDate | saveFileName = this.pro_name+"_"+startDate+'_'+ endDate | ||||
| break | break | ||||
| } | } | ||||
| case "monthly":{ | case "monthly":{ | ||||
| var temp=new Date(now - 1000 * 60 * 60 * 24 * 30) | var temp=new Date(now - 1000 * 60 * 60 * 24 * 30) | ||||
| startDate = this.saveFormatDate(temp.getFullYear(),temp.getMonth()+1,temp.getDate()); | |||||
| endDate = today | |||||
| startDate = this.formatDate(temp.getFullYear(),temp.getMonth()+1,temp.getDate()); | |||||
| startDate = this.comparedate(startDate,this.recordBeginTime) | |||||
| endDate = yesterday | |||||
| saveFileName = this.pro_name+"_"+startDate+'_'+ endDate | saveFileName = this.pro_name+"_"+startDate+'_'+ endDate | ||||
| break | break | ||||
| } | } | ||||
| case "current_year":{ | case "current_year":{ | ||||
| startDate = this.saveFormatDate(now.getFullYear(), 1, 1); | |||||
| endDate = today | |||||
| startDate = this.formatDate(now.getFullYear(), 1, 1); | |||||
| startDate = this.comparedate(startDate,this.recordBeginTime) | |||||
| endDate = yesterday | |||||
| saveFileName = this.pro_name+"_"+startDate+'_'+ endDate | saveFileName = this.pro_name+"_"+startDate+'_'+ endDate | ||||
| break | break | ||||
| } | } | ||||
| case "all":{ | case "all":{ | ||||
| console.log("e:"+today) | console.log("e:"+today) | ||||
| startDate = 'all' | startDate = 'all' | ||||
| endDate = today | |||||
| saveFileName = this.pro_name+'_all' | |||||
| endDate = yesterday | |||||
| saveFileName = this.pro_name+'_所有' | |||||
| break | break | ||||
| } | } | ||||
| } | } | ||||
| @@ -604,7 +621,7 @@ | |||||
| this.pro_id=pro_id; | this.pro_id=pro_id; | ||||
| this.ownerName=ownerName | this.ownerName=ownerName | ||||
| this.getOneProData(pro_id); | this.getOneProData(pro_id); | ||||
| this.getOneProList(pro_id,"monthly",true,5); | |||||
| this.getOneProList(pro_id,"current_year",true,0); | |||||
| this.getOneProList(pro_id,"monthly",false,5); | this.getOneProList(pro_id,"monthly",false,5); | ||||
| }, | }, | ||||
| tableHeaderStyle({row,column,rowIndex,columnIndex}){ | tableHeaderStyle({row,column,rowIndex,columnIndex}){ | ||||
| @@ -665,7 +682,7 @@ | |||||
| }, | }, | ||||
| drawRadarOpenI(){ | drawRadarOpenI(){ | ||||
| var ydata = [this.roundingF(this.tableDataIDTotal.impact),this.roundingF(this.tableDataIDTotal.completeness),this.roundingF(this.tableDataIDTotal.liveness),this.tableDataIDTotal.projectHealth,this.roundingF(this.tableDataIDTotal.teamHealth),this.roundingF(this.tableDataIDTotal.growth)] | |||||
| var ydata = [this.roundingF(this.tableDataIDTotal.impact),this.roundingF(this.tableDataIDTotal.completeness),this.roundingF(this.tableDataIDTotal.liveness),this.roundingF(this.tableDataIDTotal.projectHealth),this.roundingF(this.tableDataIDTotal.teamHealth),this.roundingF(this.tableDataIDTotal.growth)] | |||||
| console.log("ydata:",ydata) | console.log("ydata:",ydata) | ||||
| var i = -1; | var i = -1; | ||||
| var option = { | var option = { | ||||
| @@ -840,9 +857,9 @@ | |||||
| // if () | // if () | ||||
| for(var i =0;i<this.tableDataID.length;i++){ | for(var i =0;i<this.tableDataID.length;i++){ | ||||
| xdata.push(this.tableDataID[this.tableDataID.length-1-i].date); | xdata.push(this.tableDataID[this.tableDataID.length-1-i].date); | ||||
| ydata_view.push(this.roundingF(this.tableDataID[this.tableDataID.length-1-i].view)) | |||||
| ydata_download.push(this.roundingF(this.tableDataID[this.tableDataID.length-1-i].download)) | |||||
| ydata_commit.push(this.roundingF(this.tableDataID[this.tableDataID.length-1-i].commit)) | |||||
| ydata_view.push(this.tableDataID[this.tableDataID.length-1-i].view) | |||||
| ydata_download.push(this.tableDataID[this.tableDataID.length-1-i].download) | |||||
| ydata_commit.push(this.tableDataID[this.tableDataID.length-1-i].commit) | |||||
| } | } | ||||
| console.log("ydata_openI:"+ydata_download) | console.log("ydata_openI:"+ydata_download) | ||||
| console.log(xdata) | console.log(xdata) | ||||
| @@ -961,14 +978,29 @@ | |||||
| this.echartsSelectData.setOption(this.option); | this.echartsSelectData.setOption(this.option); | ||||
| // }); | // }); | ||||
| } | |||||
| }, | |||||
| comparedate(date1,date2){ | |||||
| console.log("date1:"+date1) | |||||
| console.log("date1:"+date2) | |||||
| var oDate1 = new Date(date1); | |||||
| var oDate2 = new Date(date2); | |||||
| if(oDate1.getTime() < oDate2.getTime()){ | |||||
| var data = date2.split('-') | |||||
| return data[0]+''+data[1]+''+data[2] | |||||
| } else { | |||||
| var data = date1.split('-') | |||||
| return data[0]+''+data[1]+''+data[2] | |||||
| } | |||||
| }, | |||||
| }, | }, | ||||
| filters:{ | filters:{ | ||||
| rounding (value) { | rounding (value) { | ||||
| return Number(value).toFixed(2) | return Number(value).toFixed(2) | ||||
| }, | }, | ||||
| changeType(value){ | changeType(value){ | ||||
| if(value=='false'){ | |||||
| if(value==false){ | |||||
| return "否" | return "否" | ||||
| }else{ | }else{ | ||||
| return "是" | return "是" | ||||
| @@ -1074,9 +1106,21 @@ | |||||
| .btn:active{ | .btn:active{ | ||||
| background-color:#409effd6 ; | background-color:#409effd6 ; | ||||
| } */ | } */ | ||||
| /deep/ .el-date-picker { | |||||
| width: 200px; | |||||
| /* /deep/ .el-date-picker { | |||||
| width: 250px; | |||||
| } */ | |||||
| /deep/ .el-table tbody tr:hover>td { | |||||
| background-color:#D3D3D3!important; | |||||
| opacity:1 | |||||
| } | } | ||||
| /deep/ .el-table { | |||||
| font-size: 12px; | |||||
| } | |||||
| /deep/ .el-range-separator{ | |||||
| width: 20% !important; | |||||
| } | |||||
| .colorChange { | .colorChange { | ||||
| background-color: #409effd6; | background-color: #409effd6; | ||||
| color: #FFFF; | color: #FFFF; | ||||
| @@ -5,18 +5,18 @@ | |||||
| </div> | </div> | ||||
| <div style="margin-top: 20px;"> | <div style="margin-top: 20px;"> | ||||
| <span class="sta_iterm">统计周期:</span> | <span class="sta_iterm">统计周期:</span> | ||||
| <button type="button" class='btn' id ="yesterday_usr" v-bind:class="{colorChange:1==dynamic}" @click="getUserList('yesterday_usr',1)">昨天</button> | |||||
| <button type="button" class='btn' id = "current_week_usr" v-bind:class="{colorChange:2==dynamic}" @click="getUserList('current_week_usr',2)">本周</button> | |||||
| <button type="button" class='btn' id = "current_month_usr" v-bind:class="{colorChange:3==dynamic}" @click="getUserList('current_month_usr',3)">本月</button> | |||||
| <button type="button" class='btn' id = "last_month_usr" v-bind:class="{colorChange:4==dynamic}" @click="getUserList('last_month_usr',4)">上月</button> | |||||
| <button type="button" class='btn' id = "monthly_usr" v-bind:class="{colorChange:5==dynamic}" @click="getUserList('monthly_usr',5)">近30天</button> | |||||
| <button type="button" class='btn' id = "current_year_usr" v-bind:class="{colorChange:6==dynamic}" @click="getUserList('current_year_usr',6)">今年</button> | |||||
| <button type="button" class='btn' id = "all_usr" v-bind:class="{colorChange:7==dynamic}" @click="getUserList('all_usr',7)">所有</button> | |||||
| <button type="button" class='btn' id ="yesterday_usr" v-bind:class="{colorChange:1==dynamic}" @click="resetPage(),getUserList('yesterday_usr',1)">昨天</button> | |||||
| <button type="button" class='btn' id = "current_week_usr" v-bind:class="{colorChange:2==dynamic}" @click="resetPage(),getUserList('current_week_usr',2)">本周</button> | |||||
| <button type="button" class='btn' id = "current_month_usr" v-bind:class="{colorChange:3==dynamic}" @click="resetPage(),getUserList('current_month_usr',3)">本月</button> | |||||
| <button type="button" class='btn' id = "last_month_usr" v-bind:class="{colorChange:4==dynamic}" @click="resetPage(),getUserList('last_month_usr',4)">上月</button> | |||||
| <button type="button" class='btn' id = "monthly_usr" v-bind:class="{colorChange:5==dynamic}" @click="resetPage(),getUserList('monthly_usr',5)">近30天</button> | |||||
| <button type="button" class='btn' id = "current_year_usr" v-bind:class="{colorChange:6==dynamic}" @click="resetPage(),getUserList('current_year_usr',6)">今年</button> | |||||
| <button type="button" class='btn' id = "all_usr" v-bind:class="{colorChange:7==dynamic}" @click="resetPage(),getUserList('all_usr',7)">所有</button> | |||||
| <span style="margin-left: 20px;"> | <span style="margin-left: 20px;"> | ||||
| <el-date-picker | <el-date-picker | ||||
| v-model="value_time" | v-model="value_time" | ||||
| prefix-icon="el-icon-time" | prefix-icon="el-icon-time" | ||||
| @change="getUserList('',0)" | |||||
| @change="resetPage(),getUserList('',0)" | |||||
| type="daterange" | type="daterange" | ||||
| size='small' | size='small' | ||||
| unlink-panels | unlink-panels | ||||
| @@ -28,17 +28,17 @@ | |||||
| <span style="float:right; margin-right: 20px;" > | <span style="float:right; margin-right: 20px;" > | ||||
| <a style="display:inline-block;margin-left: 20px; " id = 'download'> | <a style="display:inline-block;margin-left: 20px; " id = 'download'> | ||||
| <i class="el-icon-download"></i> | <i class="el-icon-download"></i> | ||||
| <span ><a @click="exportData()">下载报告</a> </span> | |||||
| <span ><a :href= "'../tool/query_user_static_page/?startDate='+this.params.startDate+'&endDate='+this.params.endDate+'&IsReturnFile=true'+'&userName='+this.params.userName" >下载报告</a> </span> | |||||
| </a> | </a> | ||||
| <span style="display:inline-block;margin-left: 20px; "> | <span style="display:inline-block;margin-left: 20px; "> | ||||
| <el-input size="small" placeholder="输入用户名搜索" v-model="search" class="input-with-select" @keyup.enter.native="searchName() "><i slot="suffix" class="el-input__icon el-icon-search"></i> | |||||
| <el-input size="small" placeholder="输入用户名搜索" v-model="search" class="input-with-select" @keyup.enter.native="searchName() "><i slot="suffix" class="el-input__icon el-icon-search" @click="searchName() "></i> | |||||
| </el-input> | </el-input> | ||||
| </span> | </span> | ||||
| </span> | </span> | ||||
| </div> | </div> | ||||
| <div style="margin-top: 30px;"> | <div style="margin-top: 30px;"> | ||||
| <el-table | <el-table | ||||
| :data="tableData.slice((currentPage-1)*pageSize,currentPage*pageSize)" | |||||
| :data="tableData" | |||||
| style="width: 100%" | style="width: 100%" | ||||
| :header-cell-style="tableHeaderStyle" | :header-cell-style="tableHeaderStyle" | ||||
| :cell-style='cellStyle'> | :cell-style='cellStyle'> | ||||
| @@ -123,18 +123,18 @@ | |||||
| label="用户注册时间" | label="用户注册时间" | ||||
| width="120px" | width="120px" | ||||
| align="center"> | align="center"> | ||||
| <!-- <template slot-scope="scope"> | |||||
| <template slot-scope="scope"> | |||||
| {{scope.row.RegistDate | transformTimestamp}} | {{scope.row.RegistDate | transformTimestamp}} | ||||
| </template> --> | |||||
| </template> | |||||
| </el-table-column> | </el-table-column> | ||||
| <el-table-column | <el-table-column | ||||
| prop="CountDate" | prop="CountDate" | ||||
| label="系统统计时间" | label="系统统计时间" | ||||
| width="120px" | width="120px" | ||||
| align="center"> | align="center"> | ||||
| <!-- <template slot-scope="scope"> | |||||
| <template slot-scope="scope"> | |||||
| {{scope.row.CountDate | transformTimestamp}} | {{scope.row.CountDate | transformTimestamp}} | ||||
| </template> --> | |||||
| </template> | |||||
| </el-table-column> | </el-table-column> | ||||
| </el-table> | </el-table> | ||||
| </div> | </div> | ||||
| @@ -142,10 +142,10 @@ | |||||
| <el-pagination | <el-pagination | ||||
| background | background | ||||
| @current-change="handleCurrentChange" | @current-change="handleCurrentChange" | ||||
| :current-page="currentPage" | |||||
| :current-page="page" | |||||
| :page-size="pageSize" | :page-size="pageSize" | ||||
| layout="prev, pager, next" | layout="prev, pager, next" | ||||
| :total="tableData.length"> | |||||
| :total="totalNum"> | |||||
| </el-pagination> | </el-pagination> | ||||
| </div> | </div> | ||||
| @@ -161,17 +161,17 @@ | |||||
| type_val:'', | type_val:'', | ||||
| recordBeginTime:'', | recordBeginTime:'', | ||||
| lastUpdatedTime:'', | lastUpdatedTime:'', | ||||
| currentPage:1, | |||||
| page:1, | |||||
| pageSize:10, | pageSize:10, | ||||
| params:{startDate:'',endDate:''}, | |||||
| params:{startDate:'',endDate:'',page:1,pageSize:10,userName:''}, | |||||
| tableData: [], | tableData: [], | ||||
| totalNum:0, | |||||
| pickerOptions: { | pickerOptions: { | ||||
| }, | }, | ||||
| value_time: '', | value_time: '', | ||||
| search:'', | search:'', | ||||
| data:'', | data:'', | ||||
| columns: [{title: 'ID',key: 'ID'},{title: '用户名',key: 'Name'},{title: 'PR数',key: 'CodeMergeCount'},{title: 'cimmit数',key:'CommitCount'},{title: '提出任务数',key: 'IssueCount'},{title: '评论数',key: 'CommentCount'},{title: '关注项目数',key: 'FocusRepoCount'},{title: '点赞项目数',key: 'StarRepoCount'},{title: '登录次数',key: 'LoginCount'},{title:'关注者数',key:'WatchedCount'},{title:'commit代码行数',key:'CommitCodeSize'},{title:'已解决任务数',key:'SolveIssueCount'},{title:'百科页面贡献次数',key:'EncyclopediasCount'},{title:'创建项目',key:'CreateRepoCount'},{title:'用户注册时间',key:'RegistDate'},{title:'系统统计时间',key:'CountDate'}], | |||||
| columns: [{title: 'ID',key: 'ID'},{title: '用户名',key: 'Name'},{title: 'PR数',key: 'CodeMergeCount'},{title: 'commit数',key:'CommitCount'},{title: '提出任务数',key: 'IssueCount'},{title: '评论数',key: 'CommentCount'},{title: '关注项目数',key: 'FocusRepoCount'},{title: '点赞项目数',key: 'StarRepoCount'},{title: '登录次数',key: 'LoginCount'},{title:'关注者数',key:'WatchedCount'},{title:'commit代码行数',key:'CommitCodeSize'},{title:'已解决任务数',key:'SolveIssueCount'},{title:'百科页面贡献次数',key:'EncyclopediasCount'},{title:'创建项目',key:'CreateRepoCount'},{title:'用户注册时间',key:'RegistDate'},{title:'系统统计时间',key:'CountDate'}], | |||||
| blob:'', | blob:'', | ||||
| fileName:'', | fileName:'', | ||||
| dynamic:7, | dynamic:7, | ||||
| @@ -200,8 +200,15 @@ | |||||
| return saveFileName | return saveFileName | ||||
| }, | }, | ||||
| handleCurrentChange(currentPage){ | |||||
| this.currentPage = currentPage; | |||||
| handleCurrentChange(val){ | |||||
| this.params.page = val | |||||
| this.page = val | |||||
| this.getUserList(this.type_val,this.dynamic) | |||||
| }, | |||||
| resetPage(){ | |||||
| this.page=1 | |||||
| this.params.page = 1 | |||||
| }, | }, | ||||
| formatDate(myyear,mymonth,myweekday) { | formatDate(myyear,mymonth,myweekday) { | ||||
| // var myyear = this.date.getFullYear(); | // var myyear = this.date.getFullYear(); | ||||
| @@ -224,7 +231,14 @@ | |||||
| let days = (monthEndDate - monthStartDate)/(1000 * 60 * 60 * 24); | let days = (monthEndDate - monthStartDate)/(1000 * 60 * 60 * 24); | ||||
| return days; | return days; | ||||
| }, | }, | ||||
| getUpdateTime(){ | |||||
| this.$axios.get('../api/v1/projectboard/project',{ | |||||
| params:this.params_pro | |||||
| }).then((res)=>{ | |||||
| this.recordBeginTime=res.data.recordBeginTime | |||||
| this.lastUpdatedTime=res.data.lastUpdatedTime | |||||
| }) | |||||
| }, | |||||
| getUserList(type_val,index){ | getUserList(type_val,index){ | ||||
| this.type_val = type_val | this.type_val = type_val | ||||
| this.dynamic = index; | this.dynamic = index; | ||||
| @@ -295,50 +309,63 @@ | |||||
| } | } | ||||
| case "all_usr":{ | case "all_usr":{ | ||||
| console.log("e:"+today) | console.log("e:"+today) | ||||
| this.params.startDate = this.recordBeginTime//this.formatDate(2000, 1, 1); // | |||||
| this.params.startDate = 'all'//this.formatDate(2000, 1, 1); //this.recordBeginTime// | |||||
| this.params.endDate = today | this.params.endDate = today | ||||
| this.value_time=[] | this.value_time=[] | ||||
| break | break | ||||
| } | } | ||||
| } | } | ||||
| }; | }; | ||||
| this.$axios.get('../tool/query_user_static',{ | |||||
| this.$axios.get('../tool/query_user_static_page',{ | |||||
| params:this.params | params:this.params | ||||
| }).then((res)=>{ | }).then((res)=>{ | ||||
| this.currentPage = 1 | |||||
| this.tableData = res.data | |||||
| console.log(" this.tableData:", this.tableData.length) | |||||
| for(var i=0;i<this.tableData.length;i++){ | |||||
| this.tableData[i].RegistDate = this.transformTimestamp(this.tableData[i].RegistDate) | |||||
| this.tableData[i].CountDate = this.transformTimestamp(this.tableData[i].CountDate) | |||||
| console.log(" this.tableData:", this.tableData[i].RegistDate) | |||||
| } | |||||
| }) | |||||
| this.$axios.get('../api/v1/projectboard/project',{ | |||||
| params:this.params_pro | |||||
| }).then((res)=>{ | |||||
| this.recordBeginTime=res.data.recordBeginTime | |||||
| this.lastUpdatedTime=res.data.lastUpdatedTime | |||||
| this.tableData = res.data.data | |||||
| // console.log("res.data:"+res.data.data) | |||||
| this.totalNum = res.data.count | |||||
| console.log("res.count:"+res.data.count) | |||||
| }) | }) | ||||
| // this.$axios.get('../tool/query_user_static',{ | |||||
| // params:this.params | |||||
| // }).then((res)=>{ | |||||
| // this.currentPage = 1 | |||||
| // this.tableData = res.data | |||||
| // console.log(" this.tableData:", this.tableData.length) | |||||
| // for(var i=0;i<this.tableData.length;i++){ | |||||
| // this.tableData[i].RegistDate = this.transformTimestamp(this.tableData[i].RegistDate) | |||||
| // this.tableData[i].CountDate = this.transformTimestamp(this.tableData[i].CountDate) | |||||
| // console.log(" this.tableData:", this.tableData[i].RegistDate) | |||||
| // } | |||||
| // }) | |||||
| }, | }, | ||||
| searchName(){ | searchName(){ | ||||
| // this.params.q = this.search | // this.params.q = this.search | ||||
| // this.params.page = 1 | // this.params.page = 1 | ||||
| // this.getUserList("all_usr") | // this.getUserList("all_usr") | ||||
| var search = this.search; | |||||
| this.getUserList("all_usr",7) | |||||
| this.tableData = this.tableData.filter(data => !search || data.Name.toLowerCase().includes(search.toLowerCase())) | |||||
| // var search = this.search; | |||||
| // this.getUserList("all_usr",7) | |||||
| // this.tableData = this.tableData.filter(data => !search || data.Name.toLowerCase().includes(search.toLowerCase())) | |||||
| }, | |||||
| goToDetailPage(pro_id,pro_name){ | |||||
| sessionStorage.setItem("pro_id",pro_id); | |||||
| sessionStorage.setItem("pro_name",pro_name); | |||||
| document.getElementById("pro_main").style.display="none"; | |||||
| document.getElementById("pro_detail").style.display="block"; | |||||
| this.params.userName = this.search | |||||
| this.params.page = 1 | |||||
| this.page=1 | |||||
| this.getUserList(this.type_val, this.dynamic) | |||||
| }, | }, | ||||
| // goToDetailPage(pro_id,pro_name){ | |||||
| // sessionStorage.setItem("pro_id",pro_id); | |||||
| // sessionStorage.setItem("pro_name",pro_name); | |||||
| // document.getElementById("pro_main").style.display="none"; | |||||
| // document.getElementById("pro_detail").style.display="block"; | |||||
| // }, | |||||
| tableHeaderStyle({row,column,rowIndex,columnIndex}){ | tableHeaderStyle({row,column,rowIndex,columnIndex}){ | ||||
| if(rowIndex===0){ | if(rowIndex===0){ | ||||
| @@ -351,6 +378,11 @@ | |||||
| return 'background:#f5f5f6;color:#606266' | return 'background:#f5f5f6;color:#606266' | ||||
| } | } | ||||
| }, | }, | ||||
| }, | |||||
| filters:{ | |||||
| transformTimestamp(timestamp){ | transformTimestamp(timestamp){ | ||||
| console.log("timestamp",timestamp) | console.log("timestamp",timestamp) | ||||
| let a = new Date(timestamp*1000); | let a = new Date(timestamp*1000); | ||||
| @@ -365,9 +397,6 @@ | |||||
| console.log('dateString', dateString); // > dateString 2021-07-06 14:23 | console.log('dateString', dateString); // > dateString 2021-07-06 14:23 | ||||
| return dateString; | return dateString; | ||||
| }, | }, | ||||
| }, | |||||
| filters:{ | |||||
| // transformTimestamp(timestamp){ | // transformTimestamp(timestamp){ | ||||
| // var dateString= new Date(timestamp); | // var dateString= new Date(timestamp); | ||||
| @@ -377,8 +406,8 @@ | |||||
| }, | }, | ||||
| mounted() { | mounted() { | ||||
| document.getElementById("all_usr").style.outline="none" | |||||
| document.getElementById("all_usr").focus() | |||||
| // document.getElementById("all_usr").style.outline="none" | |||||
| // document.getElementById("all_usr").focus() | |||||
| this.getUserList("all_usr",7) | this.getUserList("all_usr",7) | ||||
| }, | }, | ||||
| created() { | created() { | ||||
| @@ -386,9 +415,15 @@ | |||||
| }, | }, | ||||
| watch:{ | watch:{ | ||||
| search(val){ | search(val){ | ||||
| // if(!val){ | |||||
| // this.getUserList("all_usr",7) | |||||
| // } | |||||
| if(!val){ | if(!val){ | ||||
| this.getUserList("all_usr",7) | |||||
| } | |||||
| this.params.userName = this.search | |||||
| this.params.page = 1 | |||||
| this.page=1 | |||||
| this.getUserList(this.type_val, this.dynamic) | |||||
| } | |||||
| } | } | ||||
| }, | }, | ||||
| } | } | ||||
| @@ -426,12 +461,19 @@ | |||||
| .btn:active{ | .btn:active{ | ||||
| background-color:#409effd6 ; | background-color:#409effd6 ; | ||||
| } */ | } */ | ||||
| /deep/ .el-date-picker { | |||||
| width: 200px; | |||||
| } | |||||
| /* /deep/ .el-date-picker { | |||||
| width: 220px; | |||||
| } */ | |||||
| /deep/ .el-table { | /deep/ .el-table { | ||||
| font-size: 12px; | font-size: 12px; | ||||
| } | } | ||||
| /deep/ .el-table tbody tr:hover>td { | |||||
| background-color:#D3D3D3!important; | |||||
| opacity:1 | |||||
| } | |||||
| /deep/ .el-range-separator{ | |||||
| width: 20% !important; | |||||
| } | |||||
| .colorChange { | .colorChange { | ||||
| background-color: #409effd6; | background-color: #409effd6; | ||||