summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-08-11 14:40:03 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-08-11 14:40:03 +0000
commite80a893ff0ea8466099f6478183631af55933db2 (patch)
tree58b07a7faf58a768711a975715f91c1e6334d9d8 /lib/api
parent9c11894a656603c59c03d8f35fbe8cdf7a1ad0c4 (diff)
parentaac1de46c9be659b74da12f704412f38292974db (diff)
downloadgitlab-ce-e80a893ff0ea8466099f6478183631af55933db2.tar.gz
Merge branch 'split-events-into-push-events' into 'master'
Use a separate table for storing push events See merge request !12463
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/entities.rb12
-rw-r--r--lib/api/v3/entities.rb12
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 3bb1910a441..18cd604a216 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -497,14 +497,24 @@ module API
expose :author, using: Entities::UserBasic
end
+ class PushEventPayload < Grape::Entity
+ expose :commit_count, :action, :ref_type, :commit_from, :commit_to
+ expose :ref, :commit_title
+ end
+
class Event < Grape::Entity
expose :title, :project_id, :action_name
expose :target_id, :target_iid, :target_type, :author_id
- expose :data, :target_title
+ expose :target_title
expose :created_at
expose :note, using: Entities::Note, if: ->(event, options) { event.note? }
expose :author, using: Entities::UserBasic, if: ->(event, options) { event.author }
+ expose :push_event_payload,
+ as: :push_data,
+ using: PushEventPayload,
+ if: -> (event, _) { event.push? }
+
expose :author_username do |event, options|
event.author&.username
end
diff --git a/lib/api/v3/entities.rb b/lib/api/v3/entities.rb
index 4a2e9c9cbb0..a9a35f2a4bd 100644
--- a/lib/api/v3/entities.rb
+++ b/lib/api/v3/entities.rb
@@ -25,14 +25,24 @@ module API
expose(:downvote?) { |note| false }
end
+ class PushEventPayload < Grape::Entity
+ expose :commit_count, :action, :ref_type, :commit_from, :commit_to
+ expose :ref, :commit_title
+ end
+
class Event < Grape::Entity
expose :title, :project_id, :action_name
expose :target_id, :target_type, :author_id
- expose :data, :target_title
+ expose :target_title
expose :created_at
expose :note, using: Entities::Note, if: ->(event, options) { event.note? }
expose :author, using: ::API::Entities::UserBasic, if: ->(event, options) { event.author }
+ expose :push_event_payload,
+ as: :push_data,
+ using: PushEventPayload,
+ if: -> (event, _) { event.push? }
+
expose :author_username do |event, options|
event.author&.username
end