diff options
author | Stan Hu <stanhu@gmail.com> | 2016-07-05 18:48:03 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-07-05 18:48:03 +0300 |
commit | 5323fe418b4ce6e9c28dac9a6b975d7ec604ec0e (patch) | |
tree | 47e21d423135d9f1bfb91566214670a9ca9564a3 /app | |
parent | 670073765a29293624eee68adf778e3ae174e6c0 (diff) | |
parent | c7b68b6e66a487b8b12556fe10dd1dde78581eca (diff) |
Merge branch 'rs-avatar_url-performance' into 'master'
Dumb-down avatar presence check in `avatar_url` methods
`avatar.present?` goes through CarrierWave, and checks that the file
exists on disk and checks its filesize. Because we're hitting the disk,
this adds extra overhead to something where the worst-case scenario is
rendering a broken image.
Instead, we now just check that the _database attribute_ is present,
which is good enough for our purposes.
See https://gitlab.com/gitlab-org/gitlab-ce/issues/19273
See merge request !5093
Diffstat (limited to 'app')
-rw-r--r-- | app/models/group.rb | 2 | ||||
-rw-r--r-- | app/models/project.rb | 2 | ||||
-rw-r--r-- | app/models/user.rb | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index a8be7004ee8..37631b99701 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -90,7 +90,7 @@ class Group < Namespace end def avatar_url(size = nil) - if avatar.present? + if self[:avatar].present? [gitlab_config.url, avatar.url].join end end diff --git a/app/models/project.rb b/app/models/project.rb index ae96f00a705..e5fae15cb19 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -701,7 +701,7 @@ class Project < ActiveRecord::Base end def avatar_url - if avatar.present? + if self[:avatar].present? [gitlab_config.url, avatar.url].join elsif avatar_in_git Gitlab::Routing.url_helpers.namespace_project_avatar_url(namespace, self) diff --git a/app/models/user.rb b/app/models/user.rb index 5036a3e300c..695a47ba6eb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -653,7 +653,7 @@ class User < ActiveRecord::Base end def avatar_url(size = nil, scale = 2) - if avatar.present? + if self[:avatar].present? [gitlab_config.url, avatar.url].join else GravatarService.new.execute(email, size, scale) |