Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
b5659c29d412
Commit
c26d392b
authored
Dec 11, 2013
by
Drew Blessing
Browse files
Expire event cache on avatar creation/removal
parent
01e4765374a6
Changes
4
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
b5659c29
...
...
@@ -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 @
b5659c29
...
...
@@ -6,6 +6,8 @@ def destroy
@user
.
remove_avatar!
@user
.
save
@user
.
reset_events_cache
redirect_to
profile_path
end
end
app/models/user.rb
View file @
b5659c29
...
...
@@ -404,4 +404,18 @@ def can_leave_project?(project)
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 @
b5659c29
...
...
@@ -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 @@ def secure_url
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