diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2019-02-25 10:57:34 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2019-02-25 17:15:16 +0300 |
commit | abe8cbe90b06f4355b6a783eb22bf46154569ec5 (patch) | |
tree | 2689f8f59c74d811b1a67d5da36c15d06c84b0cd /lib | |
parent | 48d31abc97528a36614b545f0b61fa14053ce4a8 (diff) |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/projects.rb | 6 |
1 files changed, 5 insertions, 1 deletions
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' |