Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
8df699a3
Commit
8df699a3
authored
Jun 06, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: project events
parent
543506f3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
115 additions
and
1 deletion
+115
-1
app/models/event.rb
app/models/event.rb
+3
-1
doc/api/projects.md
doc/api/projects.md
+69
-0
lib/api/entities.rb
lib/api/entities.rb
+6
-0
lib/api/projects.rb
lib/api/projects.rb
+14
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+23
-0
No files found.
app/models/event.rb
View file @
8df699a3
...
@@ -75,7 +75,9 @@ class Event < ActiveRecord::Base
...
@@ -75,7 +75,9 @@ class Event < ActiveRecord::Base
end
end
def
target_title
def
target_title
target
.
try
:title
if
target
&&
target
.
respond_to?
(
:title
)
target
.
title
end
end
end
def
push?
def
push?
...
...
doc/api/projects.md
View file @
8df699a3
...
@@ -77,6 +77,7 @@ Parameters:
...
@@ -77,6 +77,7 @@ Parameters:
{
{
"id"
:
5
,
"id"
:
5
,
"name"
:
"gitlab"
,
"name"
:
"gitlab"
,
"name_with_namespace"
:
"GitLab / gitlabhq"
,
"description"
:
null
,
"description"
:
null
,
"default_branch"
:
"api"
,
"default_branch"
:
"api"
,
"owner"
:
{
"owner"
:
{
...
@@ -99,6 +100,74 @@ Parameters:
...
@@ -99,6 +100,74 @@ Parameters:
}
}
```
```
### Get project events
Get a project events for specific project.
Sorted from newest to latest
```
GET /projects/:id/events
```
Parameters:
+
`id`
(required) - The ID or NAME of a project
```
json
[{
"title"
:
null
,
"project_id"
:
15
,
"action_name"
:
"closed"
,
"target_id"
:
830
,
"target_type"
:
"Issue"
,
"author_id"
:
1
,
"data"
:
null
,
"target_title"
:
"Public project search field"
},
{
"title"
:
null
,
"project_id"
:
15
,
"action_name"
:
"opened"
,
"target_id"
:
null
,
"target_type"
:
null
,
"author_id"
:
1
,
"data"
:
{
"before"
:
"50d4420237a9de7be1304607147aec22e4a14af7"
,
"after"
:
"c5feabde2d8cd023215af4d2ceeb7a64839fc428"
,
"ref"
:
"refs/heads/master"
,
"user_id"
:
1
,
"user_name"
:
"Dmitriy Zaporozhets"
,
"repository"
:
{
"name"
:
"gitlabhq"
,
"url"
:
"git@dev.gitlab.org:gitlab/gitlabhq.git"
,
"description"
:
"GitLab: self hosted Git management software.
\r\n
Distributed under the MIT License."
,
"homepage"
:
"https://dev.gitlab.org/gitlab/gitlabhq"
},
"commits"
:
[{
"id"
:
"c5feabde2d8cd023215af4d2ceeb7a64839fc428"
,
"message"
:
"Add simple search to projects in public area"
,
"timestamp"
:
"2013-05-13T18:18:08+00:00"
,
"url"
:
"https://dev.gitlab.org/gitlab/gitlabhq/commit/c5feabde2d8cd023215af4d2ceeb7a64839fc428"
,
"author"
:
{
"name"
:
"Dmitriy Zaporozhets"
,
"email"
:
"dmitriy.zaporozhets@gmail.com"
}
}],
"total_commits_count"
:
1
},
"target_title"
:
null
},
{
"title"
:
null
,
"project_id"
:
15
,
"action_name"
:
"closed"
,
"target_id"
:
840
,
"target_type"
:
"Issue"
,
"author_id"
:
1
,
"data"
:
null
,
"target_title"
:
"Finish & merge Code search PR"
}]
```
### Create project
### Create project
...
...
lib/api/entities.rb
View file @
8df699a3
...
@@ -120,5 +120,11 @@ module API
...
@@ -120,5 +120,11 @@ module API
expose
:note
expose
:note
expose
:author
,
using:
Entities
::
UserBasic
expose
:author
,
using:
Entities
::
UserBasic
end
end
class
Event
<
Grape
::
Entity
expose
:title
,
:project_id
,
:action_name
expose
:target_id
,
:target_type
,
:author_id
expose
:data
,
:target_title
end
end
end
end
end
lib/api/projects.rb
View file @
8df699a3
...
@@ -41,6 +41,20 @@ module API
...
@@ -41,6 +41,20 @@ module API
present
user_project
,
with:
Entities
::
Project
present
user_project
,
with:
Entities
::
Project
end
end
# Get a single project events
#
# Parameters:
# id (required) - The ID of a project
# Example Request:
# GET /projects/:id
get
":id/events"
do
limit
=
(
params
[
:per_page
]
||
20
).
to_i
offset
=
(
params
[
:page
]
||
0
).
to_i
*
limit
events
=
user_project
.
events
.
recent
.
limit
(
limit
).
offset
(
offset
)
present
events
,
with:
Entities
::
Event
end
# Create new project
# Create new project
#
#
# Parameters:
# Parameters:
...
...
spec/requests/api/projects_spec.rb
View file @
8df699a3
...
@@ -173,6 +173,29 @@ describe API::API do
...
@@ -173,6 +173,29 @@ describe API::API do
end
end
end
end
describe
"GET /projects/:id/events"
do
it
"should return a project events"
do
get
api
(
"/projects/
#{
project
.
id
}
/events"
,
user
)
response
.
status
.
should
==
200
json_event
=
json_response
.
first
json_event
[
'action_name'
].
should
==
'joined'
json_event
[
'project_id'
].
to_i
.
should
==
project
.
id
end
it
"should return a 404 error if not found"
do
get
api
(
"/projects/42/events"
,
user
)
response
.
status
.
should
==
404
json_response
[
'message'
].
should
==
'404 Not Found'
end
it
"should return a 404 error if user is not a member"
do
other_user
=
create
(
:user
)
get
api
(
"/projects/
#{
project
.
id
}
/events"
,
other_user
)
response
.
status
.
should
==
404
end
end
describe
"GET /projects/:id/members"
do
describe
"GET /projects/:id/members"
do
it
"should return project team members"
do
it
"should return project team members"
do
get
api
(
"/projects/
#{
project
.
id
}
/members"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/members"
,
user
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment