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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
63723ef6
Commit
63723ef6
authored
Dec 13, 2013
by
Drew Blessing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix dashboard event caching
parent
ee53b739
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
0 deletions
+47
-0
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-0
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-0
app/controllers/projects/notes_controller.rb
app/controllers/projects/notes_controller.rb
+2
-0
app/models/issue.rb
app/models/issue.rb
+14
-0
app/models/merge_request.rb
app/models/merge_request.rb
+14
-0
app/models/note.rb
app/models/note.rb
+15
-0
No files found.
app/controllers/projects/issues_controller.rb
View file @
63723ef6
...
@@ -74,6 +74,7 @@ class Projects::IssuesController < Projects::ApplicationController
...
@@ -74,6 +74,7 @@ class Projects::IssuesController < Projects::ApplicationController
def
update
def
update
@issue
.
update_attributes
(
params
[
:issue
].
merge
(
author_id_of_changes:
current_user
.
id
))
@issue
.
update_attributes
(
params
[
:issue
].
merge
(
author_id_of_changes:
current_user
.
id
))
@issue
.
reset_events_cache
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
js
format
.
js
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
63723ef6
...
@@ -97,6 +97,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -97,6 +97,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
if
@merge_request
.
update_attributes
(
params
[
:merge_request
].
merge
(
author_id_of_changes:
current_user
.
id
))
if
@merge_request
.
update_attributes
(
params
[
:merge_request
].
merge
(
author_id_of_changes:
current_user
.
id
))
@merge_request
.
reload_code
@merge_request
.
reload_code
@merge_request
.
mark_as_unchecked
@merge_request
.
mark_as_unchecked
@merge_request
.
reset_events_cache
redirect_to
[
@merge_request
.
target_project
,
@merge_request
],
notice:
'Merge request was successfully updated.'
redirect_to
[
@merge_request
.
target_project
,
@merge_request
],
notice:
'Merge request was successfully updated.'
else
else
render
"edit"
render
"edit"
...
...
app/controllers/projects/notes_controller.rb
View file @
63723ef6
...
@@ -39,6 +39,7 @@ class Projects::NotesController < Projects::ApplicationController
...
@@ -39,6 +39,7 @@ class Projects::NotesController < Projects::ApplicationController
@note
=
@project
.
notes
.
find
(
params
[
:id
])
@note
=
@project
.
notes
.
find
(
params
[
:id
])
return
access_denied!
unless
can?
(
current_user
,
:admin_note
,
@note
)
return
access_denied!
unless
can?
(
current_user
,
:admin_note
,
@note
)
@note
.
destroy
@note
.
destroy
@note
.
reset_events_cache
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
js
{
render
nothing:
true
}
format
.
js
{
render
nothing:
true
}
...
@@ -50,6 +51,7 @@ class Projects::NotesController < Projects::ApplicationController
...
@@ -50,6 +51,7 @@ class Projects::NotesController < Projects::ApplicationController
return
access_denied!
unless
can?
(
current_user
,
:admin_note
,
@note
)
return
access_denied!
unless
can?
(
current_user
,
:admin_note
,
@note
)
@note
.
update_attributes
(
params
[
:note
])
@note
.
update_attributes
(
params
[
:note
])
@note
.
reset_events_cache
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
js
do
format
.
js
do
...
...
app/models/issue.rb
View file @
63723ef6
...
@@ -64,4 +64,18 @@ class Issue < ActiveRecord::Base
...
@@ -64,4 +64,18 @@ class Issue < ActiveRecord::Base
def
gfm_reference
def
gfm_reference
"issue #
#{
iid
}
"
"issue #
#{
iid
}
"
end
end
# Reset issue events cache
#
# Since we do cache @event we need to reset cache in special cases:
# * when an issue is updated
# Events cache stored like events/23-20130109142513.
# The cache key includes updated_at timestamp.
# Thus it will automatically generate a new fragment
# when the event is updated because the key changes.
def
reset_events_cache
Event
.
where
(
target_id:
self
.
id
,
target_type:
'Issue'
).
order
(
'id DESC'
).
limit
(
100
).
update_all
(
updated_at:
Time
.
now
)
end
end
end
app/models/merge_request.rb
View file @
63723ef6
...
@@ -305,6 +305,20 @@ class MergeRequest < ActiveRecord::Base
...
@@ -305,6 +305,20 @@ class MergeRequest < ActiveRecord::Base
self
.
target_project
.
repository
.
branch_names
.
include?
(
self
.
target_branch
)
self
.
target_project
.
repository
.
branch_names
.
include?
(
self
.
target_branch
)
end
end
# Reset merge request events cache
#
# Since we do cache @event we need to reset cache in special cases:
# * when a merge request is updated
# Events cache stored like events/23-20130109142513.
# The cache key includes updated_at timestamp.
# Thus it will automatically generate a new fragment
# when the event is updated because the key changes.
def
reset_events_cache
Event
.
where
(
target_id:
self
.
id
,
target_type:
'MergeRequest'
).
order
(
'id DESC'
).
limit
(
100
).
update_all
(
updated_at:
Time
.
now
)
end
private
private
def
dump_commits
(
commits
)
def
dump_commits
(
commits
)
...
...
app/models/note.rb
View file @
63723ef6
...
@@ -239,4 +239,19 @@ class Note < ActiveRecord::Base
...
@@ -239,4 +239,19 @@ class Note < ActiveRecord::Base
def
noteable_type
=
(
sType
)
def
noteable_type
=
(
sType
)
super
(
sType
.
to_s
.
classify
.
constantize
.
base_class
.
to_s
)
super
(
sType
.
to_s
.
classify
.
constantize
.
base_class
.
to_s
)
end
end
# Reset notes events cache
#
# Since we do cache @event we need to reset cache in special cases:
# * when a note is updated
# * when a note is removed
# Events cache stored like events/23-20130109142513.
# The cache key includes updated_at timestamp.
# Thus it will automatically generate a new fragment
# when the event is updated because the key changes.
def
reset_events_cache
Event
.
where
(
target_id:
self
.
id
,
target_type:
'Note'
).
order
(
'id DESC'
).
limit
(
100
).
update_all
(
updated_at:
Time
.
now
)
end
end
end
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