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
Léo-Paul Géneau
gitlab-ce
Commits
c26d392b
Commit
c26d392b
authored
Dec 11, 2013
by
Drew Blessing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expire event cache on avatar creation/removal
parent
2934e7a9
Changes
4
Show 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 @
c26d392b
...
@@ -9,6 +9,7 @@ v 6.4.0
...
@@ -9,6 +9,7 @@ v 6.4.0
- Allow removal of avatar (Drew Blessing)
- Allow removal of avatar (Drew Blessing)
- Project web hooks now support issues and merge request events
- 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)
- 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
v 6.3.0
- API for adding gitlab-ci service
- API for adding gitlab-ci service
...
...
app/controllers/profiles/avatars_controller.rb
View file @
c26d392b
...
@@ -6,6 +6,8 @@ class Profiles::AvatarsController < ApplicationController
...
@@ -6,6 +6,8 @@ class Profiles::AvatarsController < ApplicationController
@user
.
remove_avatar!
@user
.
remove_avatar!
@user
.
save
@user
.
save
@user
.
reset_events_cache
redirect_to
profile_path
redirect_to
profile_path
end
end
end
end
app/models/user.rb
View file @
c26d392b
...
@@ -404,4 +404,18 @@ class User < ActiveRecord::Base
...
@@ -404,4 +404,18 @@ class User < ActiveRecord::Base
project
.
namespace
!=
namespace
&&
project
.
namespace
!=
namespace
&&
project
.
project_member
(
self
)
project
.
project_member
(
self
)
end
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
end
app/uploaders/attachment_uploader.rb
View file @
c26d392b
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
class
AttachmentUploader
<
CarrierWave
::
Uploader
::
Base
class
AttachmentUploader
<
CarrierWave
::
Uploader
::
Base
storage
:file
storage
:file
after
:store
,
:reset_events_cache
def
store_dir
def
store_dir
"uploads/
#{
model
.
class
.
to_s
.
underscore
}
/
#{
mounted_as
}
/
#{
model
.
id
}
"
"uploads/
#{
model
.
class
.
to_s
.
underscore
}
/
#{
mounted_as
}
/
#{
model
.
id
}
"
end
end
...
@@ -27,4 +29,8 @@ class AttachmentUploader < CarrierWave::Uploader::Base
...
@@ -27,4 +29,8 @@ class AttachmentUploader < CarrierWave::Uploader::Base
def
file_storage?
def
file_storage?
self
.
class
.
storage
==
CarrierWave
::
Storage
::
File
self
.
class
.
storage
==
CarrierWave
::
Storage
::
File
end
end
def
reset_events_cache
(
file
)
model
.
reset_events_cache
if
model
.
is_a?
(
User
)
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