From abe8cbe90b06f4355b6a783eb22bf46154569ec5 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Mon, 25 Feb 2019 08:57:34 +0100 Subject: Load repository language from the DB if detected The repository charts page used to detect the repository language for each request that was made to the page. Given the detection is an expensive operation and the same data is stored in the database the database is now serving the request. The same goes for an API endpoint that serves the languages. When a repository is empty or non-existent the languages will always be empty. And the language detection RPC isn't requested. Closes: https://gitlab.com/gitlab-org/gitlab-ce/issues/47390 --- lib/api/projects.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 6a93ef9f3ad..36ee36fbe60 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -386,7 +386,11 @@ module API desc 'Get languages in project repository' get ':id/languages' do - user_project.repository.languages.map { |language| language.values_at(:label, :value) }.to_h + if user_project.repository_languages.present? + user_project.repository_languages.map { |l| [l.name, l.share] }.to_h + else + user_project.repository.languages.map { |language| language.values_at(:label, :value) }.to_h + end end desc 'Remove a project' -- cgit v1.2.3