合并tags/v1.21.12.1
| @@ -14,7 +14,6 @@ type ContributorWithUserId struct { | |||||
| UserId int64 | UserId int64 | ||||
| IsAdmin bool | IsAdmin bool | ||||
| RelAvatarLink string | RelAvatarLink string | ||||
| Email string | |||||
| } | } | ||||
| func GetRepoKPIStats(repo *Repository) (*git.RepoKPIStats, error) { | func GetRepoKPIStats(repo *Repository) (*git.RepoKPIStats, error) { | ||||
| @@ -127,12 +126,12 @@ func getRepoKPIStats(repoPath string, wikiPath string) (*git.RepoKPIStats, error | |||||
| } | } | ||||
| func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { | |||||
| func GetTop10Contributor(repoPath string) ([]*ContributorWithUserId, error) { | |||||
| contributors, err := git.GetContributors(repoPath) | contributors, err := git.GetContributors(repoPath) | ||||
| if err != nil { | if err != nil { | ||||
| return make([]ContributorWithUserId, 0), err | |||||
| return make([]*ContributorWithUserId, 0), err | |||||
| } | } | ||||
| contributorDistinctDict := make(map[string]ContributorWithUserId, 0) | |||||
| contributorDistinctDict := make(map[string]*ContributorWithUserId, 0) | |||||
| if contributors != nil { | if contributors != nil { | ||||
| for _, contributor := range contributors { | for _, contributor := range contributors { | ||||
| if strings.Compare(contributor.Email, "") == 0 { | if strings.Compare(contributor.Email, "") == 0 { | ||||
| @@ -144,12 +143,15 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { | |||||
| value, ok := contributorDistinctDict[user.Email] | value, ok := contributorDistinctDict[user.Email] | ||||
| if !ok { | if !ok { | ||||
| contributorDistinctDict[user.Email] = ContributorWithUserId{ | |||||
| contributor, | |||||
| contributorDistinctDict[user.Email] = &ContributorWithUserId{ | |||||
| git.Contributor{ | |||||
| contributor.CommitCnt, | |||||
| user.Name, | |||||
| user.Email, | |||||
| }, | |||||
| user.ID, | user.ID, | ||||
| user.IsAdmin, | user.IsAdmin, | ||||
| user.RelAvatarLink(), | user.RelAvatarLink(), | ||||
| user.Email, | |||||
| } | } | ||||
| } else { | } else { | ||||
| @@ -159,12 +161,11 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { | |||||
| } else { | } else { | ||||
| value, ok := contributorDistinctDict[contributor.Email] | value, ok := contributorDistinctDict[contributor.Email] | ||||
| if !ok { | if !ok { | ||||
| contributorDistinctDict[contributor.Email] = ContributorWithUserId{ | |||||
| contributorDistinctDict[contributor.Email] = &ContributorWithUserId{ | |||||
| contributor, | contributor, | ||||
| -1, | -1, | ||||
| false, | false, | ||||
| "", | "", | ||||
| contributor.Email, | |||||
| } | } | ||||
| } else { | } else { | ||||
| value.CommitCnt += contributor.CommitCnt | value.CommitCnt += contributor.CommitCnt | ||||
| @@ -173,7 +174,7 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { | |||||
| } | } | ||||
| } | } | ||||
| v := make([]ContributorWithUserId, 0, len(contributorDistinctDict)) | |||||
| v := make([]*ContributorWithUserId, 0, len(contributorDistinctDict)) | |||||
| for _, value := range contributorDistinctDict { | for _, value := range contributorDistinctDict { | ||||
| v = append(v, value) | v = append(v, value) | ||||
| } | } | ||||
| @@ -188,7 +189,7 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { | |||||
| return v[0:10], nil | return v[0:10], nil | ||||
| } | } | ||||
| } | } | ||||
| return make([]ContributorWithUserId, 0), nil | |||||
| return make([]*ContributorWithUserId, 0), nil | |||||
| } | } | ||||
| func setKeyContributerDict(contributorDistinctDict map[string]int, email string, keyContributorsDict map[string]struct{}) { | func setKeyContributerDict(contributorDistinctDict map[string]int, email string, keyContributorsDict map[string]struct{}) { | ||||
| @@ -90,15 +90,7 @@ type UserBusinessAnalysisList []*UserBusinessAnalysis | |||||
| func (ulist UserBusinessAnalysisList) Swap(i, j int) { ulist[i], ulist[j] = ulist[j], ulist[i] } | func (ulist UserBusinessAnalysisList) Swap(i, j int) { ulist[i], ulist[j] = ulist[j], ulist[i] } | ||||
| func (ulist UserBusinessAnalysisList) Len() int { return len(ulist) } | func (ulist UserBusinessAnalysisList) Len() int { return len(ulist) } | ||||
| func (ulist UserBusinessAnalysisList) Less(i, j int) bool { | func (ulist UserBusinessAnalysisList) Less(i, j int) bool { | ||||
| if ulist[i].CommitCount > ulist[j].CommitCount { | |||||
| return true | |||||
| } else { | |||||
| if ulist[i].CommitCount == ulist[j].CommitCount { | |||||
| return ulist[i].ID > ulist[j].ID | |||||
| } else { | |||||
| return false | |||||
| } | |||||
| } | |||||
| return ulist[i].ID > ulist[j].ID | |||||
| } | } | ||||
| func QueryUserStaticData(startTime int64, endTime int64) []*UserBusinessAnalysis { | func QueryUserStaticData(startTime int64, endTime int64) []*UserBusinessAnalysis { | ||||
| @@ -199,17 +191,16 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus | |||||
| } | } | ||||
| statictisSess.Limit(opts.PageSize, start) | statictisSess.Limit(opts.PageSize, start) | ||||
| } | } | ||||
| statictisSess.OrderBy("count_date desc") | |||||
| userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0) | userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0) | ||||
| if err := statictisSess.Table("user_business_analysis").Where(cond). | |||||
| if err := statictisSess.Table("user_business_analysis").Where(cond).OrderBy("id desc"). | |||||
| Find(&userBusinessAnalysisList); err != nil { | Find(&userBusinessAnalysisList); err != nil { | ||||
| return nil, 0 | return nil, 0 | ||||
| } | } | ||||
| resultMap := make(map[int64]*UserBusinessAnalysis) | resultMap := make(map[int64]*UserBusinessAnalysis) | ||||
| if opts.Page >= 0 && opts.PageSize > 0 && len(userBusinessAnalysisList) > 0 { | |||||
| if 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 { | ||||
| @@ -228,9 +219,8 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus | |||||
| builder.Lte{"count_date": opts.EndTime}, | 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).OrderBy("count_date desc"). | |||||
| Find(&userBusinessAnalysisList); err != nil { | Find(&userBusinessAnalysisList); err != nil { | ||||
| return nil, 0 | return nil, 0 | ||||
| } | } | ||||
| @@ -362,7 +362,7 @@ func generateRadarSql(beginTime time.Time, endTime time.Time, repoId int64) stri | |||||
| } | } | ||||
| func generateTargetSql(beginTime time.Time, endTime time.Time, repoId int64) string { | func generateTargetSql(beginTime time.Time, endTime time.Time, repoId int64) string { | ||||
| sql := "SELECT date, num_visits,num_downloads,num_commits FROM repo_statistic" + | |||||
| sql := "SELECT date, num_visits,num_downloads_added as num_downloads,num_commits_added as num_commits FROM repo_statistic" + | |||||
| " where repo_id=" + strconv.FormatInt(repoId, 10) + " and created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) + | " where repo_id=" + strconv.FormatInt(repoId, 10) + " and created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) + | ||||
| " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) + " order by created_unix desc" | " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) + " order by created_unix desc" | ||||
| @@ -217,7 +217,7 @@ | |||||
| > | > | ||||
| <el-table-column | <el-table-column | ||||
| label="用户名" | label="用户名" | ||||
| align="center" | |||||
| align="left" | |||||
| prop="user"> | prop="user"> | ||||
| <template slot-scope="scope"> | <template slot-scope="scope"> | ||||
| <a v-if="scope.row.mode!=-1" :href="AppSubUrl +'../../../'+ scope.row.user"><img class="ui avatar s16 image js-popover-card" :src="scope.row.relAvatarLink">{{scope.row.user}} </a> | <a v-if="scope.row.mode!=-1" :href="AppSubUrl +'../../../'+ scope.row.user"><img class="ui avatar s16 image js-popover-card" :src="scope.row.relAvatarLink">{{scope.row.user}} </a> | ||||
| @@ -1144,6 +1144,11 @@ | |||||
| created() { | created() { | ||||
| // this.download_a=document.getElementById("download_file") | // this.download_a=document.getElementById("download_file") | ||||
| }, | |||||
| updated(){ | |||||
| if(document.querySelectorAll('img[avatar]').length!==0){ | |||||
| window.LetterAvatar.transform() | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| </script> | </script> | ||||
| @@ -1201,7 +1206,7 @@ | |||||
| } | } | ||||
| .items{ | .items{ | ||||
| text-align: center; | text-align: center; | ||||
| border-right:2px solid rgba(219, 219, 219, 100); | |||||
| border-right:1px solid rgba(219, 219, 219, 100); | |||||
| } | } | ||||
| .item_l{ | .item_l{ | ||||
| margin-right: 5px; | margin-right: 5px; | ||||
| @@ -1213,6 +1218,7 @@ | |||||
| margin-right:5px; | margin-right:5px; | ||||
| border:1px solid rgba(219, 219, 219, 100); | border:1px solid rgba(219, 219, 219, 100); | ||||
| height: 370px; | height: 370px; | ||||
| overflow:auto | |||||
| } | } | ||||
| .item_echart{ | .item_echart{ | ||||
| margin-top: 10px; | margin-top: 10px; | ||||
| @@ -1224,5 +1230,6 @@ | |||||
| .item_content{ | .item_content{ | ||||
| color: #409eff; | color: #409eff; | ||||
| margin-top: 10px; | margin-top: 10px; | ||||
| font-weight:bold; | |||||
| } | } | ||||
| </style> | </style> | ||||
| @@ -149,7 +149,7 @@ | |||||
| @current-change="handleCurrentChange" | @current-change="handleCurrentChange" | ||||
| :current-page="page" | :current-page="page" | ||||
| :page-size="pageSize" | :page-size="pageSize" | ||||
| :page-sizes="[2,5,10,20]" | |||||
| :page-sizes="[5,10,20]" | |||||
| layout="total, sizes, prev, pager, next,jumper" | layout="total, sizes, prev, pager, next,jumper" | ||||
| :total="totalNum"> | :total="totalNum"> | ||||
| </el-pagination> | </el-pagination> | ||||
| @@ -423,6 +423,7 @@ | |||||
| mounted() { | mounted() { | ||||
| // document.getElementById("all_usr").style.outline="none" | // document.getElementById("all_usr").style.outline="none" | ||||
| // document.getElementById("all_usr").focus() | // document.getElementById("all_usr").focus() | ||||
| this.getUpdateTime() | |||||
| this.getUserList("all_usr",7) | this.getUserList("all_usr",7) | ||||
| }, | }, | ||||
| created() { | created() { | ||||