Browse Source

Merge pull request '用户运营统计功能:请求增加adminReq,关注者逻辑纠正,在查询时,结束时间自动加1' (#833) from zouap_static into V20211115

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/833
Reviewed-by: lewis <747342561@qq.com>
pull/836/head
lewis 3 years ago
parent
commit
ad428b2c85
3 changed files with 11 additions and 6 deletions
  1. +7
    -4
      models/user_business_analysis.go
  2. +2
    -0
      routers/repo/user_data_analysis.go
  3. +2
    -2
      routers/routes/routes.go

+ 7
- 4
models/user_business_analysis.go View File

@@ -73,6 +73,8 @@ type UserBusinessAnalysis struct {

//user
Name string `xorm:"NOT NULL"`

DataDate string `xorm:"NOT NULL"`
}

type UserBusinessAnalysisQueryOptions struct {
@@ -263,7 +265,7 @@ func CounDataByDate(wikiCountMap map[string]int, startTime time.Time, endTime ti
end_unix := endTime.Unix()

CountDate := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 1, 0, 0, currentTimeNow.Location())
DataDate := startTime.Format("2006-01-02")
CodeMergeCountMap := queryPullRequest(start_unix, end_unix)
CommitCountMap := queryAction(start_unix, end_unix, 5)
IssueCountMap := queryAction(start_unix, end_unix, 10)
@@ -300,6 +302,7 @@ func CounDataByDate(wikiCountMap map[string]int, startTime time.Time, endTime ti
dateRecord.RegistDate = userRecord.CreatedUnix
dateRecord.Name = userRecord.Name
dateRecord.GiteaAgeMonth = subMonth(currentTimeNow, userRecord.CreatedUnix.AsTime())
dateRecord.DataDate = DataDate
if _, ok := CodeMergeCountMap[dateRecord.ID]; !ok {
dateRecord.CodeMergeCount = 0
} else {
@@ -522,10 +525,10 @@ func queryFollow(start_unix int64, end_unix int64) map[int64]int {
resultMap := make(map[int64]int)
log.Info("query Follow size=" + fmt.Sprint(len(followList)))
for _, followRecord := range followList {
if _, ok := resultMap[followRecord.UserID]; !ok {
resultMap[followRecord.UserID] = 1
if _, ok := resultMap[followRecord.FollowID]; !ok {
resultMap[followRecord.FollowID] = 1
} else {
resultMap[followRecord.UserID] += 1
resultMap[followRecord.FollowID] += 1
}
}
return resultMap


+ 2
- 0
routers/repo/user_data_analysis.go View File

@@ -18,6 +18,7 @@ func QueryUserStaticData(ctx *context.Context) {
log.Info("startDate=" + startDate + " endDate=" + endDate)
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()))
ctx.JSON(http.StatusOK, models.QueryUserStaticData(startTime.Unix(), endTime.Unix()))
}
@@ -38,6 +39,7 @@ func QueryUserStaticDataPage(ctx *context.Context) {
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()))

pageOpts := &models.UserBusinessAnalysisQueryOptions{


+ 2
- 2
routers/routes/routes.go View File

@@ -792,8 +792,8 @@ func RegisterRoutes(m *macaron.Macaron) {
}, reqSignIn, context.RepoAssignment(), context.UnitTypes(), reqRepoAdmin, context.RepoRef())

m.Post("/:username/:reponame/action/:action", reqSignIn, context.RepoAssignment(), context.UnitTypes(), repo.Action)
m.Get("/tool/query_user_static", repo.QueryUserStaticData)
m.Get("/tool/query_user_static_page", repo.QueryUserStaticDataPage)
m.Get("/tool/query_user_static", adminReq, repo.QueryUserStaticData)
m.Get("/tool/query_user_static_page", adminReq, repo.QueryUserStaticDataPage)
// Grouping for those endpoints not requiring authentication
m.Group("/:username/:reponame", func() {
m.Get("/contributors", repo.Contributors)


Loading…
Cancel
Save