Browse Source

Merge pull request '提交代码。增加用户运营统计信息失败发送邮件功能。' (#865) from zouap_static into V20211115

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/865
Reviewed-by: ychao_1983 <ychao_1983@sina.com>
tags/v1.21.12.1
ychao_1983 4 years ago
parent
commit
b768f5dadc
2 changed files with 16 additions and 6 deletions
  1. +7
    -3
      models/user_business_analysis.go
  2. +9
    -3
      routers/repo/user_data_analysis.go

+ 7
- 3
models/user_business_analysis.go View File

@@ -246,7 +246,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 +394,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) {


+ 9
- 3
routers/repo/user_data_analysis.go View File

@@ -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"
) )


@@ -142,10 +143,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 +182,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) {


Loading…
Cancel
Save