about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-04-28 18:16:42 +0200
committerClaire <claire.github-309c@sitedethib.com>2022-04-28 18:16:42 +0200
commitf23f784f1811a5e7ae82faaf8868e389e9608f5d (patch)
tree77b919683a8656a361d7d62c8745233bc8b2d310 /app/workers
parent6a9d1549484a6fb02d7d01e884577a7185302046 (diff)
parent8284110c55679b7ce7b3922cb0559620b03ca88c (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/distribution_worker.rb3
-rw-r--r--app/workers/merge_worker.rb3
-rw-r--r--app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb7
3 files changed, 8 insertions, 5 deletions
diff --git a/app/workers/distribution_worker.rb b/app/workers/distribution_worker.rb
index 770325ccf..474b4daaf 100644
--- a/app/workers/distribution_worker.rb
+++ b/app/workers/distribution_worker.rb
@@ -2,9 +2,10 @@
 
 class DistributionWorker
   include Sidekiq::Worker
+  include Redisable
 
   def perform(status_id, options = {})
-    RedisLock.acquire(redis: Redis.current, key: "distribute:#{status_id}", autorelease: 5.minutes.seconds) do |lock|
+    RedisLock.acquire(redis: redis, key: "distribute:#{status_id}", autorelease: 5.minutes.seconds) do |lock|
       if lock.acquired?
         FanOutOnWriteService.new.call(Status.find(status_id), **options.symbolize_keys)
       else
diff --git a/app/workers/merge_worker.rb b/app/workers/merge_worker.rb
index 6ebb9a400..e526d2887 100644
--- a/app/workers/merge_worker.rb
+++ b/app/workers/merge_worker.rb
@@ -2,12 +2,13 @@
 
 class MergeWorker
   include Sidekiq::Worker
+  include Redisable
 
   def perform(from_account_id, into_account_id)
     FeedManager.instance.merge_into_home(Account.find(from_account_id), Account.find(into_account_id))
   rescue ActiveRecord::RecordNotFound
     true
   ensure
-    Redis.current.del("account:#{into_account_id}:regeneration")
+    redis.del("account:#{into_account_id}:regeneration")
   end
 end
diff --git a/app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb b/app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb
index 7195f0ff9..bd92fe32c 100644
--- a/app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb
+++ b/app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb
@@ -2,6 +2,7 @@
 
 class Scheduler::AccountsStatusesCleanupScheduler
   include Sidekiq::Worker
+  include Redisable
 
   # This limit is mostly to be nice to the fediverse at large and not
   # generate too much traffic.
@@ -83,14 +84,14 @@ class Scheduler::AccountsStatusesCleanupScheduler
   end
 
   def last_processed_id
-    Redis.current.get('account_statuses_cleanup_scheduler:last_account_id')
+    redis.get('account_statuses_cleanup_scheduler:last_account_id')
   end
 
   def save_last_processed_id(id)
     if id.nil?
-      Redis.current.del('account_statuses_cleanup_scheduler:last_account_id')
+      redis.del('account_statuses_cleanup_scheduler:last_account_id')
     else
-      Redis.current.set('account_statuses_cleanup_scheduler:last_account_id', id, ex: 1.hour.seconds)
+      redis.set('account_statuses_cleanup_scheduler:last_account_id', id, ex: 1.hour.seconds)
     end
   end
 end