summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHannes Rosenögger <123haynes@gmail.com>2015-07-02 13:27:02 +0000
committerHannes Rosenögger <123haynes@gmail.com>2015-07-02 13:27:02 +0000
commitd2f903c2d077fec1efbbe014b09fd576ccb268ec (patch)
tree7231f785549a798c462a2b348370b3171c9afd33
parent7c42aaa5763e6028e6c004fa7f90a3c9b2d27ccc (diff)
parent63a4dd53920882cf993459b3483d70073e75fae0 (diff)
downloadgitlab-ce-d2f903c2d077fec1efbbe014b09fd576ccb268ec.tar.gz
Merge branch 'feature/recent_order' into 'master'
'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. See merge request !825
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/event.rb2
2 files changed, 2 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 7763ccf7c70..1c16ff728a5 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -32,6 +32,7 @@ v 7.13.0 (unreleased)
- Better performance for pages with events list, issues list and commits list
- Faster automerge check and merge itself when source and target branches are in same repository
- Correctly show anonymous authorized applications under Profile > Applications.
+ - Query Optimization in MySQL.
v 7.12.1
- Fix error when deleting a user who has projects (Stan Hu)
diff --git a/app/models/event.rb b/app/models/event.rb
index c9a88ffa8e0..78f16c6304e 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -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) }