'created_at DESC' is performed twice
If you are already sorting in descending order in the created_at, it is run twice when you run the .recent. It has passed in the string 'created_at DESC'. Ruby on Rails is directly given to the SQL. It is a slow query in MySQL.
This commit is contained in:
parent
7c42aaa576
commit
87ac590078
1 changed files with 1 additions and 1 deletions
|
@ -44,7 +44,7 @@ class Event < ActiveRecord::Base
|
|||
after_create :reset_project_activity
|
||||
|
||||
# Scopes
|
||||
scope :recent, -> { order("created_at DESC") }
|
||||
scope :recent, -> { order(created_at: :desc) }
|
||||
scope :code_push, -> { where(action: PUSHED) }
|
||||
scope :in_projects, ->(project_ids) { where(project_id: project_ids).recent }
|
||||
scope :with_associations, -> { includes(project: :namespace) }
|
||||
|
|
Loading…
Reference in a new issue