Browse Source

Maintenance: Update dependency rubocop-rails to v2.25.0

renovatebot 9 months ago
parent
commit
da77305696

+ 3 - 3
Gemfile.lock

@@ -464,7 +464,7 @@ GEM
       rspec-expectations (~> 3.12)
       rspec-mocks (~> 3.12)
       rspec-support (~> 3.12)
-    racc (1.7.3)
+    racc (1.8.0)
     rack (2.2.9)
     rack-attack (6.7.0)
       rack (>= 1.0, < 4)
@@ -514,7 +514,7 @@ GEM
       ffi (~> 1.0)
     rchardet (1.8.0)
     redis (4.8.1)
-    regexp_parser (2.9.0)
+    regexp_parser (2.9.2)
     rexml (3.2.8)
       strscan (>= 3.0.9)
     rotp (6.3.0)
@@ -567,7 +567,7 @@ GEM
     rubocop-performance (1.21.0)
       rubocop (>= 1.48.1, < 2.0)
       rubocop-ast (>= 1.31.1, < 2.0)
-    rubocop-rails (2.24.1)
+    rubocop-rails (2.25.0)
       activesupport (>= 4.2.0)
       rack (>= 1.1)
       rubocop (>= 1.33.0, < 2.0)

+ 1 - 1
app/jobs/active_job_lock_cleanup_job.rb

@@ -4,6 +4,6 @@ class ActiveJobLockCleanupJob < ApplicationJob
   include HasActiveJobLock
 
   def perform(diff = 1.day)
-    ::ActiveJobLock.where('created_at < ?', Time.zone.now - diff).destroy_all
+    ::ActiveJobLock.where(created_at: ...diff.ago).destroy_all
   end
 end

+ 1 - 2
app/jobs/taskbar_cleanup_job.rb

@@ -5,8 +5,7 @@ class TaskbarCleanupJob < ApplicationJob
 
   def perform
     Taskbar
-      .where(app: :mobile)
-      .where('last_contact < ?', LAST_CONTACT_THRESHOLD.ago)
+      .where(app: :mobile, last_contact: ...LAST_CONTACT_THRESHOLD.ago)
       .destroy_all
   end
 end

+ 8 - 3
app/jobs/upload_cache_cleanup_job.rb

@@ -5,9 +5,14 @@ class UploadCacheCleanupJob < ApplicationJob
     taskbar_form_ids = Taskbar.with_form_id.filter_map(&:persisted_form_id)
     return if store_object_id.blank?
 
-    Store.where(store_object_id: store_object_id).where('created_at < ?', 1.month.ago).where.not(o_id: taskbar_form_ids).find_each do |store|
-      Store.remove_item(store.id)
-    end
+    Store
+      .where(store_object_id: store_object_id, created_at: ...1.month.ago)
+      .where.not(o_id: taskbar_form_ids)
+      .in_batches do |batch|
+        batch
+          .pluck(:id)
+          .each { |elem| Store.remove_item(elem) }
+      end
   end
 
   private

+ 3 - 1
app/models/activity_stream.rb

@@ -125,7 +125,9 @@ optional you can put the max oldest stream entries as argument
 =end
 
   def self.cleanup(diff = 3.months)
-    ActivityStream.where('created_at < ?', Time.zone.now - diff).delete_all
+    where(created_at: ...diff.ago)
+      .delete_all
+
     true
   end
 

+ 21 - 17
app/models/chat.rb

@@ -557,10 +557,9 @@ optional you can put the max oldest chat entries
 =end
 
   def self.cleanup(diff = 12.months)
-    Chat::Session.where(state: 'closed').where('updated_at < ?', Time.zone.now - diff).each do |chat_session|
-      Chat::Message.where(chat_session_id: chat_session.id).delete_all
-      chat_session.destroy
-    end
+    Chat::Session
+      .where(state: 'closed', updated_at: ...diff.ago)
+      .each(&:destroy)
 
     true
   end
@@ -578,20 +577,25 @@ optional you can put the max oldest chat sessions as argument
 =end
 
   def self.cleanup_close(diff = 5.minutes)
-    Chat::Session.where.not(state: 'closed').where('updated_at < ?', Time.zone.now - diff).each do |chat_session|
-      next if chat_session.recipients_active?
+    Chat::Session
+      .where.not(state: 'closed')
+      .where(updated_at: ...diff.ago)
+      .each do |chat_session|
+        next if chat_session.recipients_active?
+
+        chat_session.state = 'closed'
+        chat_session.save
+
+        message = {
+          event: 'chat_session_closed',
+          data:  {
+            session_id: chat_session.session_id,
+            realname:   'System',
+          },
+        }
+        chat_session.send_to_recipients(message)
+      end
 
-      chat_session.state = 'closed'
-      chat_session.save
-      message = {
-        event: 'chat_session_closed',
-        data:  {
-          session_id: chat_session.session_id,
-          realname:   'System',
-        },
-      }
-      chat_session.send_to_recipients(message)
-    end
     true
   end
 

+ 1 - 1
app/models/chat/session.rb

@@ -9,7 +9,7 @@ class Chat::Session < ApplicationModel
   include Chat::Session::Assets
 
   # rubocop:disable Rails/InverseOf
-  has_many   :messages, class_name: 'Chat::Message', foreign_key: 'chat_session_id', dependent: :destroy
+  has_many   :messages, class_name: 'Chat::Message', foreign_key: 'chat_session_id', dependent: :delete_all
   belongs_to :user,     class_name: 'User', optional: true
   belongs_to :chat,     class_name: 'Chat'
   # rubocop:enable Rails/InverseOf

+ 3 - 1
app/models/cti/log.rb

@@ -487,7 +487,9 @@ optional you can put the max oldest chat entries as argument
 =end
 
     def self.cleanup(diff = 12.months)
-      Cti::Log.where('created_at < ?', Time.zone.now - diff).delete_all
+      where(created_at: ...diff.ago)
+        .delete_all
+
       true
     end
 

+ 3 - 1
app/models/data_privacy_task.rb

@@ -27,7 +27,9 @@ class DataPrivacyTask < ApplicationModel
   end
 
   def self.cleanup(diff = 12.months)
-    where('created_at < ?', diff.ago).destroy_all
+    where(created_at: ...diff.ago)
+      .destroy_all
+
     true
   end
 

+ 3 - 1
app/models/http_log.rb

@@ -20,7 +20,9 @@ optional you can put the max oldest chat entries as argument
 =end
 
   def self.cleanup(diff = 1.month)
-    HttpLog.where('created_at < ?', Time.zone.now - diff).delete_all
+    where(created_at: ...diff.ago)
+      .delete_all
+
     true
   end
 

Some files were not shown because too many files changed in this diff