修复: 用户排行榜统计负数处理
This commit is contained in:
parent
38d860385d
commit
b27dc8393d
|
@ -87,14 +87,22 @@ class Cache::V2::UserDateRankService < ApplicationService
|
||||||
def set_user_rank
|
def set_user_rank
|
||||||
set_user_statistic
|
set_user_statistic
|
||||||
follow_count = $redis_cache.hget(user_date_statistic_key, "follow-count") || 0
|
follow_count = $redis_cache.hget(user_date_statistic_key, "follow-count") || 0
|
||||||
|
follow_count = follow_count.to_i < 0 ? 0 : follow_count
|
||||||
pullrequest_count = $redis_cache.hget(user_date_statistic_key, "pullrequest-count") || 0
|
pullrequest_count = $redis_cache.hget(user_date_statistic_key, "pullrequest-count") || 0
|
||||||
|
pullrequest_count = pullrequest_count.to_i < 0 ? 0 : pullrequest_count
|
||||||
issues_count = $redis_cache.hget(user_date_statistic_key, "issue-count") || 0
|
issues_count = $redis_cache.hget(user_date_statistic_key, "issue-count") || 0
|
||||||
|
issues_count = issues_count.to_i < 0 ? 0 : issues_count
|
||||||
project_count = $redis_cache.hget(user_date_statistic_key, "project-count") || 0
|
project_count = $redis_cache.hget(user_date_statistic_key, "project-count") || 0
|
||||||
|
project_count = project_count.to_i < 0 ? 0 : project_count
|
||||||
fork_count = $redis_cache.hget(user_date_statistic_key, "fork-count") || 0
|
fork_count = $redis_cache.hget(user_date_statistic_key, "fork-count") || 0
|
||||||
|
fork_count = fork_count.to_i < 0 ? 0 : fork_count
|
||||||
project_watchers_count = $redis_cache.hget(user_date_statistic_key, "project-watcher-count") || 0
|
project_watchers_count = $redis_cache.hget(user_date_statistic_key, "project-watcher-count") || 0
|
||||||
|
project_watchers_count = project_watchers_count.to_i < 0 ? 0 : project_watchers_count
|
||||||
project_praises_count = $redis_cache.hget(user_date_statistic_key, "project-praise-count") || 0
|
project_praises_count = $redis_cache.hget(user_date_statistic_key, "project-praise-count") || 0
|
||||||
|
project_praises_count = project_praises_count.to_i < 0 ? 0 : project_praises_count
|
||||||
project_language = $redis_cache.hget(user_date_statistic_key, "project-language")
|
project_language = $redis_cache.hget(user_date_statistic_key, "project-language")
|
||||||
project_languages_count = project_language.nil? || project_language == "{}" ? 0 : JSON.parse(project_language).length
|
project_languages_count = project_language.nil? || project_language == "{}" ? 0 : JSON.parse(project_language).length
|
||||||
|
project_languages_count = project_languages_count.to_i < 0 ? 0 : project_languages_count
|
||||||
# 影响力
|
# 影响力
|
||||||
influence = (60.0 + follow_count.to_i / (follow_count.to_i + 20.0) * 40.0).to_i
|
influence = (60.0 + follow_count.to_i / (follow_count.to_i + 20.0) * 40.0).to_i
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue