Skip to content
Snippets Groups Projects

Use a separate table for storing push events

Merged Yorick Peterse requested to merge split-events-into-push-events into master
All threads resolved!
Compare and Show latest version
18 files
+ 506
40
Compare changes
  • Side-by-side
  • Inline
Files
18
+ 15
0
@@ -48,6 +48,7 @@ class Event < ActiveRecord::Base
belongs_to :author, class_name: "User"
belongs_to :project
belongs_to :target, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
has_one :push_event_payload, foreign_key: :event_id
# For Hash only
serialize :data # rubocop:disable Cop/ActiveRecordSerialize
@@ -82,6 +83,20 @@ def find_sti_class(action)
end
end
def subclass_from_attributes(attrs)
# Without this Rails will keep calling this method on the returned class,
# resulting in an infinite loop.
return unless self == Event
action = attrs.with_indifferent_access[inheritance_column].to_i
if action == PUSHED
PushEvent
else
nil
end
end
# Update Gitlab::ContributionsCalendar#activity_dates if this changes
def contributions
where("action = ? OR (target_type IN (?) AND action IN (?)) OR (target_type = ? AND action = ?)",
Loading