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