diff options
author | Mark Fletcher <mark@gitlab.com> | 2017-05-29 13:49:17 +0800 |
---|---|---|
committer | Mark Fletcher <mark@gitlab.com> | 2017-06-06 20:16:41 +0800 |
commit | ad3e180ed3d99494414cb1b367f6b4e40ec28b87 (patch) | |
tree | 155c4e0f6b5529b3911a42ae2e8d5e80002c5a21 /app/models/event.rb | |
parent | e34e5761042579686fe149f16e7ec107b80224d2 (diff) | |
download | gitlab-ce-ad3e180ed3d99494414cb1b367f6b4e40ec28b87.tar.gz |
Introduce an Events API
* Meld the following disparate endpoints:
* `/projects/:id/events`
* `/events`
* `/users/:id/events`
+ Add result filtering to the above endpoints:
* action
* target_type
* before and after dates
Diffstat (limited to 'app/models/event.rb')
-rw-r--r-- | app/models/event.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/app/models/event.rb b/app/models/event.rb index 46e89388bc1..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 @@ -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) |