Browse Source

Maintenance: Fixing default scopes from plain sql to rails way.

Rolf Schmidt 2 years ago
parent
commit
4ed6c526f7

+ 1 - 1
app/models/core_workflow.rb

@@ -4,7 +4,7 @@ class CoreWorkflow < ApplicationModel
   include ChecksClientNotification
   include CoreWorkflow::Assets
 
-  default_scope { order('priority ASC, name ASC, id ASC') }
+  default_scope { order(:priority, :id) }
   scope :active, -> { where(active: true) }
   scope :changeable, -> { where(changeable: true) }
   scope :object, ->(object) { where(object: [object, nil]) }

+ 1 - 1
app/models/ldap_source.rb

@@ -4,7 +4,7 @@ class LdapSource < ApplicationModel
   include CanPriorization
   include ChecksClientNotification
 
-  default_scope { order('prio ASC, id ASC') }
+  default_scope { order(:prio, :id) }
   scope :active, -> { where(active: true) }
 
   store :preferences

+ 1 - 1
app/models/public_link.rb

@@ -13,7 +13,7 @@ class PublicLink < ApplicationModel
 
   before_validation :check_link
 
-  default_scope { order('prio ASC, id ASC') }
+  default_scope { order(:prio, :id) }
 
   belongs_to :created_by, class_name: 'User'
   belongs_to :updated_by, class_name: 'User'

+ 1 - 1
app/models/smime_certificate.rb

@@ -1,7 +1,7 @@
 # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
 
 class SMIMECertificate < ApplicationModel
-  default_scope { order('not_after_at DESC, not_before_at DESC, id DESC') }
+  default_scope { order(not_after_at: :desc, not_before_at: :desc, id: :desc) }
 
   validates :fingerprint, uniqueness: { case_sensitive: true }
 

+ 1 - 1
app/models/user/overview_sorting.rb

@@ -8,7 +8,7 @@ class User::OverviewSorting < ApplicationModel
   belongs_to :created_by, class_name: 'User'
   belongs_to :updated_by, class_name: 'User'
 
-  default_scope { order('prio ASC, id ASC') }
+  default_scope { order(:prio, :id) }
 
   def self.prio_create(id:, prio:, current_user:)
     overview = Overview.find(id)