提交 87f179e0 编写于 作者: R Rémy Coutable

Merge branch 'events-redundant-where' into 'master'

Remove redundant WHERE from event queries

Closes #38129

See merge request gitlab-org/gitlab-ce!14389
class Event < ActiveRecord::Base
include Sortable
include IgnorableColumn
default_scope { reorder(nil).where.not(author_id: nil) }
default_scope { reorder(nil) }
CREATED = 1
UPDATED = 2
......@@ -77,6 +77,12 @@ class Event < ActiveRecord::Base
scope :for_milestone_id, ->(milestone_id) { where(target_type: "Milestone", target_id: milestone_id) }
# Authors are required as they're used to display who pushed data.
#
# We're just validating the presence of the ID here as foreign key constraints
# should ensure the ID points to a valid user.
validates :author_id, presence: true
self.inheritance_column = 'action'
# "data" will be removed in 10.0 but it may be possible that JOINs happen that
......
......@@ -3,12 +3,6 @@ class PushEvent < Event
# different "action" value.
validate :validate_push_action
# Authors are required as they're used to display who pushed data.
#
# We're just validating the presence of the ID here as foreign key constraints
# should ensure the ID points to a valid user.
validates :author_id, presence: true
# The project is required to build links to commits, commit ranges, etc.
#
# We're just validating the presence of the ID here as foreign key constraints
......
---
title: Remove redundant WHERE from event queries
merge_request:
author:
type: other
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册