fix: user popular project nil

This commit is contained in:
yystopf 2021-10-29 19:38:49 +08:00
parent c0df55c20f
commit eba672f39a
1 changed files with 10 additions and 6 deletions

View File

@ -1,15 +1,19 @@
owner_common = $redis_cache.hgetall("v2-owner-common:#{item[0]}") owner_common = $redis_cache.hgetall("v2-owner-common:#{item[0]}")
popular_project = $redis_cache.zrevrange("v2-user-project-rank:#{item[0]}", 0, 1, withscores: true)[0] popular_project = $redis_cache.zrevrange("v2-user-project-rank:#{item[0]}", 0, 1, withscores: true)[0]
popular_project_common = $redis_cache.hgetall("v2-project-common:#{popular_project[0]}")
json.id item[0] json.id item[0]
json.score item[1] json.score item[1]
json.name owner_common["name"] json.name owner_common["name"]
json.type owner_common["type"] json.type owner_common["type"]
json.login owner_common["login"] json.login owner_common["login"]
json.avatar_url owner_common["avatar_url"] json.avatar_url owner_common["avatar_url"]
json.project do if popular_project.blank?
json.id popular_project[0] json.project nil
json.name popular_project_common["name"] else
json.identifier popular_project_common["identifier"] popular_project_common = $redis_cache.hgetall("v2-project-common:#{popular_project[0]}")
json.description popular_project_common["description"] json.project do
json.id popular_project[0]
json.name popular_project_common["name"]
json.identifier popular_project_common["identifier"]
json.description popular_project_common["description"]
end
end end