Commit d2f903c2 authored by Hannes Rosenögger's avatar Hannes Rosenögger

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
parents 7c42aaa5 63a4dd53
...@@ -32,6 +32,7 @@ v 7.13.0 (unreleased) ...@@ -32,6 +32,7 @@ v 7.13.0 (unreleased)
- Better performance for pages with events list, issues list and commits list - 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 - Faster automerge check and merge itself when source and target branches are in same repository
- Correctly show anonymous authorized applications under Profile > Applications. - Correctly show anonymous authorized applications under Profile > Applications.
- Query Optimization in MySQL.
v 7.12.1 v 7.12.1
- Fix error when deleting a user who has projects (Stan Hu) - Fix error when deleting a user who has projects (Stan Hu)
......
...@@ -44,7 +44,7 @@ class Event < ActiveRecord::Base ...@@ -44,7 +44,7 @@ class Event < ActiveRecord::Base
after_create :reset_project_activity after_create :reset_project_activity
# Scopes # Scopes
scope :recent, -> { order("created_at DESC") } scope :recent, -> { order(created_at: :desc) }
scope :code_push, -> { where(action: PUSHED) } scope :code_push, -> { where(action: PUSHED) }
scope :in_projects, ->(project_ids) { where(project_id: project_ids).recent } scope :in_projects, ->(project_ids) { where(project_id: project_ids).recent }
scope :with_associations, -> { includes(project: :namespace) } scope :with_associations, -> { includes(project: :namespace) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment