Commit 3645e684 authored by Yorick Peterse's avatar Yorick Peterse

Merge branch '23106-events-default-scope-results-in-a-slow-query' into 'master'

Optimize Event queries by removing default order

See merge request !7130
parents 05f6736d 0badbef8
Pipeline #4814437 failed with stages
in 56 minutes and 57 seconds
......@@ -28,6 +28,7 @@ Please view this file on the master branch, on stable branches it's out of date.
- Fix typo in framework css class. !7086 (Daniel Voogsgerd)
- New issue board list dropdown stays open after adding a new list
- Fix: Backup restore doesn't clear cache
- Optimize Event queries by removing default order
- API: Fix project deploy keys 400 and 500 errors when adding an existing key. !6784 (Joshua Welsh)
- Add job for removal of unreferenced LFS objects from both the database and the filesystem (Frank Groeneveld)
- Replace jquery.cookie plugin with js.cookie !7085
class Event < ActiveRecord::Base
include Sortable
default_scope { where.not(author_id: nil) }
default_scope { reorder(nil).where.not(author_id: nil) }
......@@ -20,7 +20,7 @@ describe Projects::MilestonesController do
delete :destroy, namespace_id:, project_id:, id: milestone.iid, format: :js
expect(response).to be_success
expect(Event.first.action).to eq(Event::DESTROYED)
expect(Event.recent.first.action).to eq(Event::DESTROYED)
expect { Milestone.find( }.to raise_exception(ActiveRecord::RecordNotFound)
......@@ -57,12 +57,12 @@ describe ProjectMember, models: true do
it "creates an expired event when left due to expiry" do
expired = create(:project_member, project: project, expires_at: - 6.days)
expect(Event.first.action).to eq(Event::EXPIRED)
expect(Event.recent.first.action).to eq(Event::EXPIRED)
it "creates a left event when left due to leave" do
expect(Event.first.action).to eq(Event::LEFT)
expect(Event.recent.first.action).to eq(Event::LEFT)
it "destroys itself and delete associated todos" do
......@@ -18,7 +18,7 @@ describe Milestones::CloseService, services: true do
it { expect(milestone).to be_closed }
describe :event do
let(:event) { Event.first }
let(:event) { Event.recent.first }
it { expect(event.milestone).to be_truthy }
it { expect( eq(milestone) }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment