diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-05-24 14:49:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-24 14:49:13 +0200 |
commit | 1beb8db4e26d1bd4a801b432f466d948b3b562fc (patch) | |
tree | 39de9e2163c3737f182d67ba8718cde32d6a0296 /app/models | |
parent | c279dbd47082e908d98dc8cf869c0ff7fc19f1ae (diff) | |
parent | 228ec75048a5527237720cdbaa8d6ab086ea6c84 (diff) |
Merge pull request #1779 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/admin/account_action.rb | 4 | ||||
-rw-r--r-- | app/models/trends/history.rb | 20 |
2 files changed, 13 insertions, 11 deletions
diff --git a/app/models/admin/account_action.rb b/app/models/admin/account_action.rb index 237975880..aed3bc0c7 100644 --- a/app/models/admin/account_action.rb +++ b/app/models/admin/account_action.rb @@ -164,8 +164,8 @@ class Admin::AccountAction def reports @reports ||= begin - if type == 'none' && with_report? - [report] + if type == 'none' + with_report? ? [report] : [] else Report.where(target_account: target_account).unresolved end diff --git a/app/models/trends/history.rb b/app/models/trends/history.rb index 608e33792..74723e35c 100644 --- a/app/models/trends/history.rb +++ b/app/models/trends/history.rb @@ -11,11 +11,11 @@ class Trends::History end def uses - redis.mget(*@days.map { |day| day.key_for(:uses) }).map(&:to_i).sum + with_redis { |redis| redis.mget(*@days.map { |day| day.key_for(:uses) }).map(&:to_i).sum } end def accounts - redis.pfcount(*@days.map { |day| day.key_for(:accounts) }) + with_redis { |redis| redis.pfcount(*@days.map { |day| day.key_for(:accounts) }) } end end @@ -33,19 +33,21 @@ class Trends::History attr_reader :day def accounts - redis.pfcount(key_for(:accounts)) + with_redis { |redis| redis.pfcount(key_for(:accounts)) } end def uses - redis.get(key_for(:uses))&.to_i || 0 + with_redis { |redis| redis.get(key_for(:uses))&.to_i || 0 } end def add(account_id) - redis.pipelined do - redis.incrby(key_for(:uses), 1) - redis.pfadd(key_for(:accounts), account_id) - redis.expire(key_for(:uses), EXPIRE_AFTER) - redis.expire(key_for(:accounts), EXPIRE_AFTER) + with_redis do |redis| + redis.pipelined do |pipeline| + pipeline.incrby(key_for(:uses), 1) + pipeline.pfadd(key_for(:accounts), account_id) + pipeline.expire(key_for(:uses), EXPIRE_AFTER) + pipeline.expire(key_for(:accounts), EXPIRE_AFTER) + end end end |