...
|
...
|
@@ -51,6 +51,7 @@ func ComputeRankScore() error { |
|
|
}
|
|
|
}()
|
|
|
if !atomic.CompareAndSwapInt32(&ComputeRankScoreFlag, 0, 1) {
|
|
|
log.Warn("ComputeRankScore is working", ComputeRankScoreFlag)
|
|
|
return fmt.Errorf("ComputeRankScore is working. try later")
|
|
|
} else {
|
|
|
defer utils.Profiling("ComputeRankScore 执行耗时")()
|
...
|
...
|
@@ -73,13 +74,13 @@ func computeRankScore() (err error) { |
|
|
}
|
|
|
}()
|
|
|
//1.l 查询进行中的赛季
|
|
|
if periods, err = models.GetRankPeriods([]int{protocol.RankPeriodBegin}); err != nil {
|
|
|
if periods, err = models.GetRankPeriods(0, 0, []int{protocol.RankPeriodBegin}); err != nil {
|
|
|
return
|
|
|
}
|
|
|
//2.查询对应 rank_type_id 的rank_data
|
|
|
for i := range periods {
|
|
|
period := periods[i]
|
|
|
if rankRanges, err = models.GetRankRanges(period.CompanyId); err == orm.ErrNoRows {
|
|
|
if rankRanges, err = models.GetRankRanges(period.CompanyId, period.RankTypeId); err == orm.ErrNoRows {
|
|
|
continue
|
|
|
}
|
|
|
//所有部门
|
...
|
...
|
@@ -229,7 +230,7 @@ type RankDiscovery struct{} |
|
|
|
|
|
func (rank RankDiscovery) RankUser(o RankOption) (err error, result RankResult) {
|
|
|
var (
|
|
|
sql = `select sum(discovery_score) score,count(0) total from chance where user_id =? and review_status=3
|
|
|
sql = `select sum(discovery_score) score,count(0) total from chance where user_id =? and review_status=3 and status=1
|
|
|
and UNIX_TIMESTAMP(approve_time)>=? and UNIX_TIMESTAMP(approve_time)<?`
|
|
|
score float64
|
|
|
total int
|
...
|
...
|
@@ -245,7 +246,7 @@ func (rank RankDiscovery) RankUser(o RankOption) (err error, result RankResult) |
|
|
}
|
|
|
func (rank RankDiscovery) RankDepartment(o RankOption) (err error, result RankResult) {
|
|
|
var (
|
|
|
sql = `select sum(discovery_score) score,count(0) total from chance where department_id =? and review_status=3
|
|
|
sql = `select sum(discovery_score) score,count(0) total from chance where department_id =? and review_status=3 and status=1
|
|
|
and UNIX_TIMESTAMP(approve_time)>=? and UNIX_TIMESTAMP(approve_time)<?
|
|
|
`
|
|
|
score float64
|
...
|
...
|
|