|
|
package contrab
|
|
|
|
|
|
import (
|
|
|
"bytes"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"github.com/astaxie/beego/orm"
|
...
|
...
|
@@ -62,7 +63,7 @@ func ComputeRankScore() (err error) { |
|
|
log.Warn("ComputeRankScore is working", ComputeRankScoreFlag)
|
|
|
return fmt.Errorf("ComputeRankScore is working. try later")
|
|
|
} else {
|
|
|
defer utils.Profiling("结束作业:排行榜分数计算 执行耗时")()
|
|
|
defer utils.Profiling("【排行榜分数统计】 执行耗时")()
|
|
|
}
|
|
|
defer func() {
|
|
|
atomic.CompareAndSwapInt32(&ComputeRankScoreFlag, 1, 0)
|
...
|
...
|
@@ -169,7 +170,11 @@ func computeRankScore(index int, wg sync.WaitGroup, gNum int, periods []*models. |
|
|
}
|
|
|
|
|
|
func logProcessInfo(period *models.RankPeriod) {
|
|
|
log.Debug(fmt.Sprintf("【排行榜统计】 周期编号:%v 赛季名称:%v (榜单类型:%v) ", period.Id, period.SeasonName, period.RankTypeId))
|
|
|
log.Debug(fmt.Sprintf("【排行榜统计】 公司:%v 周期编号:%v 赛季名称:%v (榜单类型:%v) ", period.CompanyId, period.Id, period.SeasonName, period.RankTypeId))
|
|
|
}
|
|
|
|
|
|
func logScoreChanceLog(itemName string, old float64, new float64) string {
|
|
|
return fmt.Sprintf(" [%v %v->%v]", itemName, old, new)
|
|
|
}
|
|
|
|
|
|
//更新排行榜按关联id
|
...
|
...
|
@@ -214,6 +219,9 @@ func updateRank(o RankOption) { |
|
|
Type: int8(o.Type),
|
|
|
}
|
|
|
} else {
|
|
|
if rank.EnableStatus == protocol.InValid {
|
|
|
rank.EnableStatus = protocol.Valid
|
|
|
}
|
|
|
rankTmp = *rank
|
|
|
}
|
|
|
o.Rank = rank
|
...
|
...
|
@@ -237,12 +245,33 @@ func updateRank(o RankOption) { |
|
|
if e = models.UpdateRankById(rank); e != nil {
|
|
|
log.Error(e)
|
|
|
}
|
|
|
log.Debug(fmt.Sprintf("【排行榜统计】 更新 周期编号:%v 公司:%v 评分者编号:%v (榜单类型:%v 参与类型:%v)", rank.RankPeriodId, rank.CompanyId, rank.RelationId, rank.RankTypeId, rank.RankRangeId))
|
|
|
log.Debug(fmt.Sprintf("【排行榜统计】 更新 周期编号:%v 公司:%v 评分者编号:%v (榜单类型:%v 参与类型:%v) %v", rank.RankPeriodId, rank.CompanyId, rank.RelationId, rank.RankTypeId, rank.RankRangeId,
|
|
|
checkScoreChange(rankTmp, *rank)))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
func checkScoreChange(old, new models.Rank) string {
|
|
|
changeLog := bytes.NewBuffer(nil)
|
|
|
if old.TotalScore != new.TotalScore {
|
|
|
changeLog.WriteString(logScoreChanceLog("总分", old.TotalScore, new.TotalScore))
|
|
|
}
|
|
|
if old.DiscoveryScore != new.DiscoveryScore {
|
|
|
changeLog.WriteString(logScoreChanceLog("发现分", old.DiscoveryScore, new.DiscoveryScore))
|
|
|
}
|
|
|
if old.GraspScore != new.GraspScore {
|
|
|
changeLog.WriteString(logScoreChanceLog("把握分", old.GraspScore, new.GraspScore))
|
|
|
}
|
|
|
if old.DiscoveryTotal != new.DiscoveryTotal {
|
|
|
changeLog.WriteString(logScoreChanceLog("发现总数", float64(old.DiscoveryTotal), float64(new.DiscoveryTotal)))
|
|
|
}
|
|
|
if old.CommentTotal != new.CommentTotal {
|
|
|
changeLog.WriteString(logScoreChanceLog("评论总数", float64(old.CommentTotal), float64(new.CommentTotal)))
|
|
|
}
|
|
|
return changeLog.String()
|
|
|
}
|
|
|
|
|
|
//更新排行榜总分 //更新总分 系数*发现分 + 系数*把握分
|
|
|
func updateTotalScore(o RankOption) {
|
|
|
var (
|
...
|
...
|
|