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
Compare and Show latest version
22 files
+ 588
112
Compare changes
  • Side-by-side
  • Inline
Files
22
+ 25
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 = ?)",
@@ -304,6 +319,16 @@ def commits
@commits ||= (data[:commits] || []).reverse
end
def commit_message
commit = commits.last
commit[:message] if commit
end
def commit_id
commit_to || commit_from
end
def commits_count
data[:total_commits_count] || commits.count || 0
end
Loading