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 /app/controllers/projects/graphs_controller.rb | |
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 'app/controllers/projects/graphs_controller.rb')
-rw-r--r-- | app/controllers/projects/graphs_controller.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/app/controllers/projects/graphs_controller.rb b/app/controllers/projects/graphs_controller.rb index 925b6ed9bfd..c80fce513f6 100644 --- a/app/controllers/projects/graphs_controller.rb +++ b/app/controllers/projects/graphs_controller.rb @@ -45,7 +45,14 @@ class Projects::GraphsController < Projects::ApplicationController end def get_languages - @languages = @project.repository.languages + @languages = + if @project.repository_languages.present? + @project.repository_languages.map do |lang| + { value: lang.share, label: lang.name, color: lang.color, highlight: lang.color } + end + else + @project.repository.languages + end end def fetch_graph |