1
|
package contrab
|
1
|
package contrab
|
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
|
|
4
|
+ "bytes"
|
4
|
"encoding/json"
|
5
|
"encoding/json"
|
5
|
"fmt"
|
6
|
"fmt"
|
6
|
"github.com/astaxie/beego/orm"
|
7
|
"github.com/astaxie/beego/orm"
|
|
@@ -62,7 +63,7 @@ func ComputeRankScore() (err error) { |
|
@@ -62,7 +63,7 @@ func ComputeRankScore() (err error) { |
62
|
log.Warn("ComputeRankScore is working", ComputeRankScoreFlag)
|
63
|
log.Warn("ComputeRankScore is working", ComputeRankScoreFlag)
|
63
|
return fmt.Errorf("ComputeRankScore is working. try later")
|
64
|
return fmt.Errorf("ComputeRankScore is working. try later")
|
64
|
} else {
|
65
|
} else {
|
65
|
- defer utils.Profiling("结束作业:排行榜分数计算 执行耗时")()
|
66
|
+ defer utils.Profiling("【排行榜分数统计】 执行耗时")()
|
66
|
}
|
67
|
}
|
67
|
defer func() {
|
68
|
defer func() {
|
68
|
atomic.CompareAndSwapInt32(&ComputeRankScoreFlag, 1, 0)
|
69
|
atomic.CompareAndSwapInt32(&ComputeRankScoreFlag, 1, 0)
|
|
@@ -169,7 +170,11 @@ func computeRankScore(index int, wg sync.WaitGroup, gNum int, periods []*models. |
|
@@ -169,7 +170,11 @@ func computeRankScore(index int, wg sync.WaitGroup, gNum int, periods []*models. |
169
|
}
|
170
|
}
|
170
|
|
171
|
|
171
|
func logProcessInfo(period *models.RankPeriod) {
|
172
|
func logProcessInfo(period *models.RankPeriod) {
|
172
|
- log.Debug(fmt.Sprintf("【排行榜统计】 周期编号:%v 赛季名称:%v (榜单类型:%v) ", period.Id, period.SeasonName, period.RankTypeId))
|
173
|
+ log.Debug(fmt.Sprintf("【排行榜统计】 公司:%v 周期编号:%v 赛季名称:%v (榜单类型:%v) ", period.CompanyId, period.Id, period.SeasonName, period.RankTypeId))
|
|
|
174
|
+}
|
|
|
175
|
+
|
|
|
176
|
+func logScoreChanceLog(itemName string, old float64, new float64) string {
|
|
|
177
|
+ return fmt.Sprintf(" [%v %v->%v]", itemName, old, new)
|
173
|
}
|
178
|
}
|
174
|
|
179
|
|
175
|
//更新排行榜按关联id
|
180
|
//更新排行榜按关联id
|
|
@@ -214,6 +219,9 @@ func updateRank(o RankOption) { |
|
@@ -214,6 +219,9 @@ func updateRank(o RankOption) { |
214
|
Type: int8(o.Type),
|
219
|
Type: int8(o.Type),
|
215
|
}
|
220
|
}
|
216
|
} else {
|
221
|
} else {
|
|
|
222
|
+ if rank.EnableStatus == protocol.InValid {
|
|
|
223
|
+ rank.EnableStatus = protocol.Valid
|
|
|
224
|
+ }
|
217
|
rankTmp = *rank
|
225
|
rankTmp = *rank
|
218
|
}
|
226
|
}
|
219
|
o.Rank = rank
|
227
|
o.Rank = rank
|
|
@@ -237,12 +245,33 @@ func updateRank(o RankOption) { |
|
@@ -237,12 +245,33 @@ func updateRank(o RankOption) { |
237
|
if e = models.UpdateRankById(rank); e != nil {
|
245
|
if e = models.UpdateRankById(rank); e != nil {
|
238
|
log.Error(e)
|
246
|
log.Error(e)
|
239
|
}
|
247
|
}
|
240
|
- log.Debug(fmt.Sprintf("【排行榜统计】 更新 周期编号:%v 公司:%v 评分者编号:%v (榜单类型:%v 参与类型:%v)", rank.RankPeriodId, rank.CompanyId, rank.RelationId, rank.RankTypeId, rank.RankRangeId))
|
248
|
+ log.Debug(fmt.Sprintf("【排行榜统计】 更新 周期编号:%v 公司:%v 评分者编号:%v (榜单类型:%v 参与类型:%v) %v", rank.RankPeriodId, rank.CompanyId, rank.RelationId, rank.RankTypeId, rank.RankRangeId,
|
|
|
249
|
+ checkScoreChange(rankTmp, *rank)))
|
241
|
}
|
250
|
}
|
242
|
}
|
251
|
}
|
243
|
|
252
|
|
244
|
}
|
253
|
}
|
245
|
|
254
|
|
|
|
255
|
+func checkScoreChange(old, new models.Rank) string {
|
|
|
256
|
+ changeLog := bytes.NewBuffer(nil)
|
|
|
257
|
+ if old.TotalScore != new.TotalScore {
|
|
|
258
|
+ changeLog.WriteString(logScoreChanceLog("总分", old.TotalScore, new.TotalScore))
|
|
|
259
|
+ }
|
|
|
260
|
+ if old.DiscoveryScore != new.DiscoveryScore {
|
|
|
261
|
+ changeLog.WriteString(logScoreChanceLog("发现分", old.DiscoveryScore, new.DiscoveryScore))
|
|
|
262
|
+ }
|
|
|
263
|
+ if old.GraspScore != new.GraspScore {
|
|
|
264
|
+ changeLog.WriteString(logScoreChanceLog("把握分", old.GraspScore, new.GraspScore))
|
|
|
265
|
+ }
|
|
|
266
|
+ if old.DiscoveryTotal != new.DiscoveryTotal {
|
|
|
267
|
+ changeLog.WriteString(logScoreChanceLog("发现总数", float64(old.DiscoveryTotal), float64(new.DiscoveryTotal)))
|
|
|
268
|
+ }
|
|
|
269
|
+ if old.CommentTotal != new.CommentTotal {
|
|
|
270
|
+ changeLog.WriteString(logScoreChanceLog("评论总数", float64(old.CommentTotal), float64(new.CommentTotal)))
|
|
|
271
|
+ }
|
|
|
272
|
+ return changeLog.String()
|
|
|
273
|
+}
|
|
|
274
|
+
|
246
|
//更新排行榜总分 //更新总分 系数*发现分 + 系数*把握分
|
275
|
//更新排行榜总分 //更新总分 系数*发现分 + 系数*把握分
|
247
|
func updateTotalScore(o RankOption) {
|
276
|
func updateTotalScore(o RankOption) {
|
248
|
var (
|
277
|
var (
|