Commit Graph

22 Commits

Author SHA1 Message Date
GitLab Bot c792263edf Add latest changes from gitlab-org/gitlab@master 2019-09-23 18:06:14 +00:00
GitLab Bot 80f61b4035 Add latest changes from gitlab-org/gitlab@master 2019-09-18 14:02:45 +00:00
Stan Hu 25818bd7ae Disable method replacement in avatar loading
We've seen a significant performance penalty when using
`BatchLoader#__replace_with!`. This defines methods on the batch loader
that proxy to the 'real' object using send. The alternative is
`method_missing`, which is slower.  However, we've noticed that
`method_missing` can be faster if:

1. The objects being loaded have a large interface.
2. We don't call too many methods on the loaded object.

Avatar uploads meet both criteria above, so let's use the newly-released
feature in https://github.com/exAspArk/batch-loader/pull/45.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/60903
2019-04-29 21:29:25 -07:00
Stan Hu 52fdddbd2d Cache avatar URLs and paths within a request
In a merge request with many discussions, the avatar URL can be called
thousands of times, inflicting a significant performance penalty
especially when avatars are stored in object storage. To mitigate this
problem, we can just cache the generated path any time it is requested.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/55355
2018-12-19 15:34:29 -08:00
Jasper Maes 5d5481519d Rails5: Passing a class as a value in an Active Record query is deprecated 2018-11-17 16:14:36 +01:00
Stan Hu d4bdcfbf19 Disable project avatar validation if avatar has not changed
Every time a column in the projects table is changed, the Avatarable concern
would validate that the avatar file size was under 200K.  This not only delays
the database changes, but it also can lead to unrelated failures if the HTTP
request fails for some reason.

Closes #51053
2018-09-04 12:20:58 -07:00
gfyoung 15b878e27e Enable more frozen string in app/models/**/*.rb
Partially addresses #47424.
2018-08-07 00:37:36 -07:00
Tim Zallmann fac4f50cf6 Send resize parameters for avatars 2018-08-07 06:04:33 +00:00
Sean McGivern 6ecf819f73 Fix an N+1 in avatar URLs
This is tricky: the query was being run in
`ObjectStorage::Extension::RecordsUploads#retrieve_from_store!`, but we can't
just add batch loading there, because the `#upload=` method there would use the
result immediately, making the batch only have one item.

Instead, we can pre-emptively add an item to the batch whenever an avatarable
object is initialized, and then reuse that batch item in
`#retrieve_from_store!`. However, this also has problems:

1. There is a lot of logic in `Avatarable#retrieve_upload_from_batch`.
2. Some of that logic constructs a 'fake' model for the batch key. This should
   be fine, because of ActiveRecord's override of `#==`, but it relies on that
   staying the same.
2018-06-05 14:57:19 +01:00
Micaël Bergeron 741f333d23 Resolve "Avatar URLs are wrong when using a CDN path and Object Storage" 2018-04-23 16:59:53 +00:00
Sean McGivern 835fe4d324 Merge branch '40781-os-to-ce' into 'master'
Bring Object Storage to CE

Closes #4171, #4163, #3370, #2841, and #29203

See merge request gitlab-org/gitlab-ce!17358
2018-03-27 08:20:03 +00:00
Fabian Schneider 839589fde3 Change avatar error message to include allowed file formats 2018-03-22 19:01:43 +01:00
Micaël Bergeron 0f1d348d68 port the object storage to CE 2018-03-01 10:34:30 -05:00
Sean McGivern a7dae52e9d Merge branch '4163-move-uploads-to-object-storage' into 'master'
Move uploads to object storage

Closes #4163

See merge request gitlab-org/gitlab-ee!3867
2018-02-28 20:58:15 +01:00
Micaël Bergeron 2057a6acde port of 594e6a0a625^..f74c90f68c6 2018-02-01 12:14:46 -05:00
Douwe Maan 2fbbba9a29 Always return full avatar URL for private/internal groups/projects when asset host is set 2017-11-09 15:40:41 +00:00
Tim Zallmann 5f41cddf80 Based on MR simplified the logic 2017-10-09 10:45:23 +02:00
Tim Zallmann d2620faff9 Updates based on MR comments 2017-10-05 16:29:45 +02:00
Tim Zallmann 1b75296875 Fixed Linting errors + tests 2017-10-04 14:27:09 +02:00
Tim Zallmann 892b02e890 Created group_icon and group_icon_url
Tests for these new helper methods
2017-10-04 14:27:09 +02:00
Tim Zallmann 79c80de99d Making private project avatars use local paths + Some Group Icons 2017-10-04 14:26:33 +02:00
blackst0ne 29a3203b3f Use relative paths for group/project/user avatars 2017-05-10 15:26:17 +11:00