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
iv
gitlab-ce
Commits
81e12570
Commit
81e12570
authored
Feb 18, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix event loading with associations
parent
fd5d8be1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
10 deletions
+25
-10
app/controllers/dashboard_controller.rb
app/controllers/dashboard_controller.rb
+11
-4
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+11
-4
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-1
app/controllers/users_controller.rb
app/controllers/users_controller.rb
+1
-1
app/models/event.rb
app/models/event.rb
+1
-0
No files found.
app/controllers/dashboard_controller.rb
View file @
81e12570
...
@@ -22,13 +22,14 @@ class DashboardController < ApplicationController
...
@@ -22,13 +22,14 @@ class DashboardController < ApplicationController
format
.
html
format
.
html
format
.
json
do
format
.
json
do
@events
=
Event
.
in_projects
(
current_user
.
authorized_projects
.
pluck
(
:id
))
load_events
@events
=
@event_filter
.
apply_filter
(
@events
).
includes
(
:target
,
project: :namespace
)
@events
=
@events
.
limit
(
20
).
offset
(
params
[
:offset
]
||
0
)
pager_json
(
"events/_events"
,
@events
.
count
)
pager_json
(
"events/_events"
,
@events
.
count
)
end
end
format
.
atom
{
render
layout:
false
}
format
.
atom
do
load_events
render
layout:
false
end
end
end
end
end
...
@@ -77,4 +78,10 @@ class DashboardController < ApplicationController
...
@@ -77,4 +78,10 @@ class DashboardController < ApplicationController
def
load_projects
def
load_projects
@projects
=
current_user
.
authorized_projects
.
sorted_by_activity
.
non_archived
@projects
=
current_user
.
authorized_projects
.
sorted_by_activity
.
non_archived
end
end
def
load_events
@events
=
Event
.
in_projects
(
current_user
.
authorized_projects
.
pluck
(
:id
))
@events
=
@event_filter
.
apply_filter
(
@events
).
with_associations
@events
=
@events
.
limit
(
20
).
offset
(
params
[
:offset
]
||
0
)
end
end
end
app/controllers/groups_controller.rb
View file @
81e12570
...
@@ -39,13 +39,14 @@ class GroupsController < ApplicationController
...
@@ -39,13 +39,14 @@ class GroupsController < ApplicationController
format
.
html
format
.
html
format
.
json
do
format
.
json
do
@events
=
Event
.
in_projects
(
project_ids
)
load_events
@events
=
event_filter
.
apply_filter
(
@events
).
includes
(
:target
,
project: :namespace
)
@events
=
@events
.
limit
(
20
).
offset
(
params
[
:offset
]
||
0
)
pager_json
(
"events/_events"
,
@events
.
count
)
pager_json
(
"events/_events"
,
@events
.
count
)
end
end
format
.
atom
{
render
layout:
false
}
format
.
atom
do
load_events
render
layout:
false
end
end
end
end
end
...
@@ -154,4 +155,10 @@ class GroupsController < ApplicationController
...
@@ -154,4 +155,10 @@ class GroupsController < ApplicationController
def
group_params
def
group_params
params
.
require
(
:group
).
permit
(
:name
,
:description
,
:path
,
:avatar
)
params
.
require
(
:group
).
permit
(
:name
,
:description
,
:path
,
:avatar
)
end
end
def
load_events
@events
=
Event
.
in_projects
(
project_ids
)
@events
=
event_filter
.
apply_filter
(
@events
).
with_associations
@events
=
@events
.
limit
(
20
).
offset
(
params
[
:offset
]
||
0
)
end
end
end
app/controllers/projects_controller.rb
View file @
81e12570
...
@@ -76,7 +76,7 @@ class ProjectsController < ApplicationController
...
@@ -76,7 +76,7 @@ class ProjectsController < ApplicationController
format
.
json
do
format
.
json
do
@events
=
@project
.
events
.
recent
@events
=
@project
.
events
.
recent
@events
=
event_filter
.
apply_filter
(
@events
).
includes
(
:target
,
project: :namespace
)
@events
=
event_filter
.
apply_filter
(
@events
).
with_associations
@events
=
@events
.
limit
(
limit
).
offset
(
params
[
:offset
]
||
0
)
@events
=
@events
.
limit
(
limit
).
offset
(
params
[
:offset
]
||
0
)
pager_json
(
'events/_events'
,
@events
.
count
)
pager_json
(
'events/_events'
,
@events
.
count
)
end
end
...
...
app/controllers/users_controller.rb
View file @
81e12570
...
@@ -20,7 +20,7 @@ class UsersController < ApplicationController
...
@@ -20,7 +20,7 @@ class UsersController < ApplicationController
# Get user activity feed for projects common for both users
# Get user activity feed for projects common for both users
@events
=
@user
.
recent_events
.
@events
=
@user
.
recent_events
.
where
(
project_id:
authorized_projects_ids
).
where
(
project_id:
authorized_projects_ids
).
includes
(
:target
,
project: :namespace
)
.
limit
(
30
)
with_associations
.
limit
(
30
)
@title
=
@user
.
name
@title
=
@user
.
name
@title_url
=
user_path
(
@user
)
@title_url
=
user_path
(
@user
)
...
...
app/models/event.rb
View file @
81e12570
...
@@ -47,6 +47,7 @@ class Event < ActiveRecord::Base
...
@@ -47,6 +47,7 @@ class Event < ActiveRecord::Base
scope
:recent
,
->
{
order
(
"created_at DESC"
)
}
scope
:recent
,
->
{
order
(
"created_at DESC"
)
}
scope
:code_push
,
->
{
where
(
action:
PUSHED
)
}
scope
:code_push
,
->
{
where
(
action:
PUSHED
)
}
scope
:in_projects
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
).
recent
}
scope
:in_projects
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
).
recent
}
scope
:with_associations
,
->
{
includes
(
project: :namespace
)
}
class
<<
self
class
<<
self
def
reset_event_cache_for
(
target
)
def
reset_event_cache_for
(
target
)
...
...
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