top用户项目排行调整
This commit is contained in:
parent
beca1b7928
commit
b4bca892b5
|
@ -1,10 +1,13 @@
|
|||
class ProjectRankController < ApplicationController
|
||||
# 根据时间获取热门项目
|
||||
def index
|
||||
def index
|
||||
limit = 9
|
||||
limit = params[:limit].to_i - 1 if params[:limit].present?
|
||||
limit = 99 if limit > 99
|
||||
$redis_cache.zunionstore("recent-days-project-rank-#{time}", get_timeable_key_names)
|
||||
deleted_data = $redis_cache.smembers("v2-project-rank-deleted")
|
||||
$redis_cache.zrem("recent-days-project-rank-#{time}", deleted_data) unless deleted_data.blank?
|
||||
@project_rank = $redis_cache.zrevrange("recent-days-project-rank-#{time}", 0, 9, withscores: true)
|
||||
@project_rank = $redis_cache.zrevrange("recent-days-project-rank-#{time}", 0, limit, withscores: true)
|
||||
rescue Exception => e
|
||||
@project_rank = []
|
||||
end
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
class UserRankController < ApplicationController
|
||||
# 根据时间获取热门开发者
|
||||
def index
|
||||
def index
|
||||
limit = 3
|
||||
limit = params[:limit].to_i - 1 if params[:limit].present?
|
||||
limit = 99 if limit > 99
|
||||
$redis_cache.zunionstore("recent-days-user-rank", get_timeable_key_names)
|
||||
@user_rank = $redis_cache.zrevrange("recent-days-user-rank", 0, 3, withscores: true)
|
||||
@user_rank = $redis_cache.zrevrange("recent-days-user-rank", 0, limit, withscores: true)
|
||||
rescue Exception => e
|
||||
@user_rank = []
|
||||
end
|
||||
|
|
|
@ -28,4 +28,5 @@ json.forks project_common["forks"]
|
|||
json.watchers project_common["watchers"]
|
||||
json.praises project_common["praises"]
|
||||
json.issues project_common["issues"]
|
||||
json.pulls project_common["pullrequests"]
|
||||
json.pulls project_common["pullrequests"]
|
||||
json.commits project_common["commits"]
|
|
@ -18,4 +18,31 @@ else
|
|||
json.identifier popular_project_common["identifier"]
|
||||
json.description popular_project_common["description"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ids = $redis_cache.zrevrange("v2-user-project-rank:#{item[0]}", 0, 999, withscores: true).map{|a|a[0]}
|
||||
visits = 0
|
||||
forks = 0
|
||||
watchers = 0
|
||||
praises = 0
|
||||
issues = 0
|
||||
pulls = 0
|
||||
commits = 0
|
||||
ids.each do |pid|
|
||||
project_common = $redis_cache.hgetall("v2-project-common:#{pid}")
|
||||
visits = visits + project_common["visits"]
|
||||
forks = forks + project_common["forks"]
|
||||
watchers = watchers + project_common["watchers"]
|
||||
praises = praises + project_common["praises"]
|
||||
issues = issues + project_common["issues"]
|
||||
pulls = pulls + project_common["pullrequests"]
|
||||
commits = commits + project_common["commits"]
|
||||
end
|
||||
|
||||
json.visits visits
|
||||
json.forks forks
|
||||
json.watchers watchers
|
||||
json.praises praises
|
||||
json.issues issues
|
||||
json.pulls pulls
|
||||
json.commits commits
|
Loading…
Reference in New Issue