Browse Source

Merge branch 'develop' into standalone_develop

pull/342/head
yystopf 3 years ago
parent
commit
c4b93f2bd3
3 changed files with 10 additions and 0 deletions
  1. +2
    -0
      app/controllers/admins/projects_rank_controller.rb
  2. +4
    -0
      app/services/cache/v2/project_date_rank_service.rb
  3. +4
    -0
      app/services/cache/v2/user_date_rank_service.rb

+ 2
- 0
app/controllers/admins/projects_rank_controller.rb View File

@@ -2,6 +2,8 @@ class Admins::ProjectsRankController < Admins::BaseController

def index
@rank_date = rank_date
deleted_data = $redis_cache.smembers("v2-project-rank-deleted")
$redis_cache.zrem("v2-project-rank-#{rank_date}", deleted_data) unless deleted_data.blank?
@date_rank = $redis_cache.zrevrange("v2-project-rank-#{rank_date}", 0, -1, withscores: true)
end



+ 4
- 0
app/services/cache/v2/project_date_rank_service.rb View File

@@ -67,5 +67,9 @@ class Cache::V2::ProjectDateRankService < ApplicationService
end

$redis_cache.zscore(project_rank_key, @project_id)

# 设置过期时间(一个月)
$redis_cache.expireat(project_rank_key, (@rank_date+30.days).to_time.to_i)
$redis_cache.expireat(project_rank_statistic_key, (@rank_date+30.days).to_time.to_i)
end
end

+ 4
- 0
app/services/cache/v2/user_date_rank_service.rb View File

@@ -115,5 +115,9 @@ class Cache::V2::UserDateRankService < ApplicationService
$redis_cache.zadd(user_rank_key, score-300, @user_id) if score > 300

$redis_cache.zscore(user_rank_key, @user_id)

# 设置过期时间(一个月)
$redis_cache.expireat(user_rank_key, (@rank_date+30.days).to_time.to_i)
$redis_cache.expireat(user_date_statistic_key, (@rank_date+30.days).to_time.to_i)
end
end

Loading…
Cancel
Save