summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-09-21 07:42:10 +0000
committerRémy Coutable <remy@rymai.me>2017-09-21 07:42:10 +0000
commit87f179e09b0ab456250534747a726708ad4e7e9b (patch)
treec5898d0b021a31b2e9d37e6618bae69b10bdec61
parentd863326ea8a184d012e81ab47fb5e4e62801a0c6 (diff)
parent9a3e4b8d1c197063bb832247657c8026f8ca307e (diff)
downloadgitlab-ce-87f179e09b0ab456250534747a726708ad4e7e9b.tar.gz
Merge branch 'events-redundant-where' into 'master'
Remove redundant WHERE from event queries Closes #38129 See merge request gitlab-org/gitlab-ce!14389
-rw-r--r--app/models/event.rb8
-rw-r--r--app/models/push_event.rb6
-rw-r--r--changelogs/unreleased/events-redundant-where.yml5
3 files changed, 12 insertions, 7 deletions
diff --git a/app/models/event.rb b/app/models/event.rb
index 0b1f053a7e6..0997b056c6a 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -1,7 +1,7 @@
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
diff --git a/app/models/push_event.rb b/app/models/push_event.rb
index 708513c7861..83ce9014094 100644
--- a/app/models/push_event.rb
+++ b/app/models/push_event.rb
@@ -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
diff --git a/changelogs/unreleased/events-redundant-where.yml b/changelogs/unreleased/events-redundant-where.yml
new file mode 100644
index 00000000000..a118a2e33e1
--- /dev/null
+++ b/changelogs/unreleased/events-redundant-where.yml
@@ -0,0 +1,5 @@
+---
+title: Remove redundant WHERE from event queries
+merge_request:
+author:
+type: other