作者 yangfu

排行榜修改

... ... @@ -86,7 +86,7 @@ func GetRanksByUser(companyId int64, rankTypeId, rankRangeId, rankPeriodId int,
(
select score,relation_id,user_id from(
select a.%v score,a.relation_id,user_id from rank a inner join user_company c on a.relation_id=c.id
where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v
where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v and a.enable_status=1
order by a.%v desc,c.create_at asc
) a,(select @rowno:=%v) b
limit %v,%v
... ... @@ -117,7 +117,7 @@ select a.*,b.nick_name name from
(
select score,relation_id,user_id,(@rowno:=@rowno+1) as ranking from(
select a.%v score,a.relation_id,user_id from rank a inner join user_company c on a.relation_id=c.id
where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v
where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v and a.enable_status=1
order by a.%v desc,c.create_at asc
) a,(select @rowno:=0 ) b
)a inner join user b on a.user_id = b.id
... ... @@ -145,7 +145,7 @@ select a.*,(@rowno:=@rowno+1) as ranking from
(
select a.%v score,a.relation_id,c.name
from rank a inner join department c on a.relation_id=c.id
where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v
where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v and a.enable_status=1
order by a.%v desc,c.create_at asc
)a,(select (@rowno:=%v)) b
limit %v,%v
... ... @@ -174,7 +174,7 @@ func GetRanksByDepartmentSelf(companyId int64, rankTypeId, rankRangeId, rankPeri
sql := fmt.Sprintf(`select * from (
select a.*,(@rowno:=@rowno+1) as ranking from (
select a.%v score,a.relation_id,c.name from rank a inner join department c on a.relation_id=c.id
where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v
where a.company_id=%v and rank_type_id=%v and rank_range_id=%v and rank_period_id=%v and a.enable_status=1
order by a.%v desc,c.create_at asc
) a,(select (@rowno:=0)) b
)a
... ... @@ -184,6 +184,9 @@ where a.relation_id=%v
if v != nil {
if err = utils.ExecuteQueryOne(v, sql); err != nil {
if err == orm.ErrNoRows {
err = nil
}
return
}
}
... ...
... ... @@ -219,10 +219,10 @@ func updateRank(o RankOption) {
Type: int8(o.Type),
}
} else {
rankTmp = *rank
if rank.EnableStatus == protocol.InValid {
rank.EnableStatus = protocol.Valid
}
rankTmp = *rank
}
o.Rank = rank
for i := range rankList {
... ... @@ -269,6 +269,9 @@ func checkScoreChange(old, new models.Rank) string {
if old.CommentTotal != new.CommentTotal {
changeLog.WriteString(logScoreChanceLog("评论总数", float64(old.CommentTotal), float64(new.CommentTotal)))
}
if old.EnableStatus != new.EnableStatus {
changeLog.WriteString(logScoreChanceLog("状态", float64(old.EnableStatus), float64(new.EnableStatus)))
}
return changeLog.String()
}
... ...