summaryrefslogtreecommitdiff
path: root/app/models/event.rb
diff options
context:
space:
mode:
authorJose Ivan Vargas Lopez <jvargas@gitlab.com>2017-06-07 23:31:06 +0000
committerJose Ivan Vargas Lopez <jvargas@gitlab.com>2017-06-07 23:31:06 +0000
commitfb80347dc00657ba36576f1f23bd42fdbcf9520a (patch)
tree2642ac39cda31e29ea80defdc71e00c89ac8979e /app/models/event.rb
parent73924cc51495f5f497114ed9f9de02f8b9c4205b (diff)
parent6eb96b2019d392d906a64108dbe83b3ce7cce758 (diff)
downloadgitlab-ce-additional-metrics-dashboard.tar.gz
Merge branch '28717-additional-metrics-review-branch' into 'additional-metrics-dashboard'additional-metrics-dashboard
# Conflicts: # app/assets/stylesheets/pages/environments.scss
Diffstat (limited to 'app/models/event.rb')
-rw-r--r--app/models/event.rb34
1 files changed, 33 insertions, 1 deletions
diff --git a/app/models/event.rb b/app/models/event.rb
index e6fad46077a..d6d39473774 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -14,6 +14,30 @@ class Event < ActiveRecord::Base
DESTROYED = 10
EXPIRED = 11 # User left project due to expiry
+ ACTIONS = HashWithIndifferentAccess.new(
+ created: CREATED,
+ updated: UPDATED,
+ closed: CLOSED,
+ reopened: REOPENED,
+ pushed: PUSHED,
+ commented: COMMENTED,
+ merged: MERGED,
+ joined: JOINED,
+ left: LEFT,
+ destroyed: DESTROYED,
+ expired: EXPIRED
+ ).freeze
+
+ TARGET_TYPES = HashWithIndifferentAccess.new(
+ issue: Issue,
+ milestone: Milestone,
+ merge_request: MergeRequest,
+ note: Note,
+ project: Project,
+ snippet: Snippet,
+ user: User
+ ).freeze
+
RESET_PROJECT_ACTIVITY_INTERVAL = 1.hour
delegate :name, :email, :public_email, :username, to: :author, prefix: true, allow_nil: true
@@ -26,7 +50,7 @@ class Event < ActiveRecord::Base
belongs_to :target, polymorphic: true
# For Hash only
- serialize :data
+ serialize :data # rubocop:disable Cop/ActiverecordSerialize
# Callbacks
after_create :reset_project_activity
@@ -55,6 +79,14 @@ class Event < ActiveRecord::Base
def limit_recent(limit = 20, offset = nil)
recent.limit(limit).offset(offset)
end
+
+ def actions
+ ACTIONS.keys
+ end
+
+ def target_types
+ TARGET_TYPES.keys
+ end
end
def visible_to_user?(user = nil)