Create Redisable#redis (#9633)
* Create Redisable * Use #redis instead of Redis.current
This commit is contained in:
parent
6a5e3da6b0
commit
bcfff65195
13 changed files with 39 additions and 59 deletions
11
app/models/concerns/redisable.rb
Normal file
11
app/models/concerns/redisable.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Redisable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
private
|
||||
|
||||
def redis
|
||||
Redis.current
|
||||
end
|
||||
end
|
|
@ -1,6 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Feed
|
||||
include Redisable
|
||||
|
||||
def initialize(type, id)
|
||||
@type = type
|
||||
@id = id
|
||||
|
@ -27,8 +29,4 @@ class Feed
|
|||
def key
|
||||
FeedManager.instance.key(@type, @id)
|
||||
end
|
||||
|
||||
def redis
|
||||
Redis.current
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,6 +7,8 @@ class TrendingTags
|
|||
THRESHOLD = 5
|
||||
|
||||
class << self
|
||||
include Redisable
|
||||
|
||||
def record_use!(tag, account, at_time = Time.now.utc)
|
||||
return if disallowed_hashtags.include?(tag.name) || account.silenced? || account.bot?
|
||||
|
||||
|
@ -59,9 +61,5 @@ class TrendingTags
|
|||
@disallowed_hashtags = @disallowed_hashtags.split(' ') if @disallowed_hashtags.is_a? String
|
||||
@disallowed_hashtags = @disallowed_hashtags.map(&:downcase)
|
||||
end
|
||||
|
||||
def redis
|
||||
Redis.current
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue