Skip to content
Snippets Groups Projects
Commit 5323fe41 authored by Stan Hu's avatar Stan Hu
Browse files

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
parents 67007376 c7b68b6e
No related branches found
No related tags found
1 merge request!5093Dumb-down avatar presence check in `avatar_url` methods
Pipeline #
Loading
@@ -90,7 +90,7 @@ class Group < Namespace
Loading
@@ -90,7 +90,7 @@ class Group < Namespace
end end
   
def avatar_url(size = nil) def avatar_url(size = nil)
if avatar.present? if self[:avatar].present?
[gitlab_config.url, avatar.url].join [gitlab_config.url, avatar.url].join
end end
end end
Loading
Loading
Loading
@@ -701,7 +701,7 @@ class Project < ActiveRecord::Base
Loading
@@ -701,7 +701,7 @@ class Project < ActiveRecord::Base
end end
   
def avatar_url def avatar_url
if avatar.present? if self[:avatar].present?
[gitlab_config.url, avatar.url].join [gitlab_config.url, avatar.url].join
elsif avatar_in_git elsif avatar_in_git
Gitlab::Routing.url_helpers.namespace_project_avatar_url(namespace, self) Gitlab::Routing.url_helpers.namespace_project_avatar_url(namespace, self)
Loading
Loading
Loading
@@ -653,7 +653,7 @@ class User < ActiveRecord::Base
Loading
@@ -653,7 +653,7 @@ class User < ActiveRecord::Base
end end
   
def avatar_url(size = nil, scale = 2) def avatar_url(size = nil, scale = 2)
if avatar.present? if self[:avatar].present?
[gitlab_config.url, avatar.url].join [gitlab_config.url, avatar.url].join
else else
GravatarService.new.execute(email, size, scale) GravatarService.new.execute(email, size, scale)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment