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
adf55958
Commit
adf55958
authored
Dec 11, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5759 from bke-drewb/issue-5496
Add cache expiry on avatar creation/removal
parents
2934e7a9
c26d392b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
0 deletions
+23
-0
CHANGELOG
CHANGELOG
+1
-0
app/controllers/profiles/avatars_controller.rb
app/controllers/profiles/avatars_controller.rb
+2
-0
app/models/user.rb
app/models/user.rb
+14
-0
app/uploaders/attachment_uploader.rb
app/uploaders/attachment_uploader.rb
+6
-0
No files found.
CHANGELOG
View file @
adf55958
...
...
@@ -9,6 +9,7 @@ v 6.4.0
- Allow removal of avatar (Drew Blessing)
- Project web hooks now support issues and merge request events
- Visiting project page while not logged in will redirect to sign-in instead of 404 (Jason Hollingsworth)
- Expire event cache on avatar creation/removal (Drew Blessing)
v 6.3.0
- API for adding gitlab-ci service
...
...
app/controllers/profiles/avatars_controller.rb
View file @
adf55958
...
...
@@ -6,6 +6,8 @@ class Profiles::AvatarsController < ApplicationController
@user
.
remove_avatar!
@user
.
save
@user
.
reset_events_cache
redirect_to
profile_path
end
end
app/models/user.rb
View file @
adf55958
...
...
@@ -404,4 +404,18 @@ class User < ActiveRecord::Base
project
.
namespace
!=
namespace
&&
project
.
project_member
(
self
)
end
# Reset project events cache related to this user
#
# Since we do cache @event we need to reset cache in special cases:
# * when the user changes their avatar
# 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
(
author_id:
self
.
id
).
order
(
'id DESC'
).
limit
(
1000
).
update_all
(
updated_at:
Time
.
now
)
end
end
app/uploaders/attachment_uploader.rb
View file @
adf55958
...
...
@@ -3,6 +3,8 @@
class
AttachmentUploader
<
CarrierWave
::
Uploader
::
Base
storage
:file
after
:store
,
:reset_events_cache
def
store_dir
"uploads/
#{
model
.
class
.
to_s
.
underscore
}
/
#{
mounted_as
}
/
#{
model
.
id
}
"
end
...
...
@@ -27,4 +29,8 @@ class AttachmentUploader < CarrierWave::Uploader::Base
def
file_storage?
self
.
class
.
storage
==
CarrierWave
::
Storage
::
File
end
def
reset_events_cache
(
file
)
model
.
reset_events_cache
if
model
.
is_a?
(
User
)
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