diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-12-08 04:35:34 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-12-08 04:35:34 +0300 |
commit | 9b561e7e15723a82e1f0dcf780aeb7fac5ec139b (patch) | |
tree | 13f3ba947c335882d7fcdd8eeb94a01abcc91285 /app/controllers/projects/graphs_controller.rb | |
parent | e02940e32941cc253f713ef3fe0aac896c9342ac (diff) |
Implement languages graph page
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/controllers/projects/graphs_controller.rb')
-rw-r--r-- | app/controllers/projects/graphs_controller.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/controllers/projects/graphs_controller.rb b/app/controllers/projects/graphs_controller.rb index 418b92040bc..c3942c52c6c 100644 --- a/app/controllers/projects/graphs_controller.rb +++ b/app/controllers/projects/graphs_controller.rb @@ -34,6 +34,26 @@ class Projects::GraphsController < Projects::ApplicationController @charts[:build_times] = Ci::Charts::BuildTime.new(ci_project) end + def languages + @languages = Linguist::Repository.new(@repository.rugged, @repository.rugged.head.target_id).languages + total = @languages.map(&:last).sum + + @languages = @languages.map do |language| + name, share = language + color = Digest::SHA256.hexdigest(name)[0...6] + { + value: (share.to_f * 100 / total).round(2), + label: name, + color: "##{color}", + highlight: "##{color}" + } + end + + @languages.sort! do |x, y| + y[:value] <=> x[:value] + end + end + private def fetch_graph |