Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-08-14 16:22:09 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2017-08-14 19:00:28 +0300
commitaef9f1eb9405e9bab92b15f5c99bf06eaf28a5d6 (patch)
tree01ebae601e9df77c1b2887e0783b73b30f833b2b /lib/api/v3/projects.rb
parent21a6898b10ed75f6260e72467b9e1f839d48456c (diff)
Cache the number of forks of a project
The number of forks of a project doesn't change very frequently and running a COUNT(*) every time this information is requested can be quite expensive. We also end up running such a COUNT(*) query at least twice on the homepage of a project. By caching this data and refreshing it when necessary we can reduce project homepage loading times by around 60 milliseconds (based on the timings of https://gitlab.com/gitlab-org/gitlab-ce).
Diffstat (limited to 'lib/api/v3/projects.rb')
-rw-r--r--lib/api/v3/projects.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/api/v3/projects.rb b/lib/api/v3/projects.rb
index eb090453b48..449876c10d9 100644
--- a/lib/api/v3/projects.rb
+++ b/lib/api/v3/projects.rb
@@ -388,6 +388,8 @@ module API
if user_project.forked_from_project.nil?
user_project.create_forked_project_link(forked_to_project_id: user_project.id, forked_from_project_id: forked_from_project.id)
+
+ ::Projects::ForksCountService.new(forked_from_project).refresh_cache
else
render_api_error!("Project already forked", 409)
end