Commit 09ccf6cc authored by Georg G's avatar Georg G

Use Linguist::Language[] instead of creating a hash

parent 35304897
......@@ -36,6 +36,7 @@ v 8.13.0 (unreleased)
- Close open merge request without source project (Katarzyna Kobierska Ula Budziszewska)
- Fix that manual jobs would no longer block jobs in the next stage. !6604
- Add configurable email subject suffix (Fu Xu)
- Use defined colour for a language when available !6748 (nilsding)
- Added tooltip to fork count on project show page. (Justin DiPierro)
- Use a ConnectionPool for Rails.cache on Sidekiq servers
- Replace `alias_method_chain` with `Module#prepend`
......
......@@ -35,14 +35,10 @@ class Projects::GraphsController < Projects::ApplicationController
def languages
@languages = Linguist::Repository.new(@repository.rugged, @repository.rugged.head.target_id).languages
total = @languages.map(&:last).sum
colors = Linguist::Language.colors.
select { |lang| @languages.include? lang.name }.
map { |lang| [lang.name, lang.color] }.
to_h
@languages = @languages.map do |language|
name, share = language
color = colors[name] || "##{Digest::SHA256.hexdigest(name)[0...6]}"
color = Linguist::Language[name].color || "##{Digest::SHA256.hexdigest(name)[0...6]}"
{
value: (share.to_f * 100 / total).round(2),
label: name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment