diff --git a/app/workers/repo_checks_worker.rb b/app/workers/repo_checks_worker.rb index a922f062..2bebeb4b 100644 --- a/app/workers/repo_checks_worker.rb +++ b/app/workers/repo_checks_worker.rb @@ -52,8 +52,8 @@ def repo_summary def detect_languages repo = Rugged::Repository.new(path) project = Linguist::Repository.new(repo, repo.head.target_id) - - top_3 = project.languages.keys.take(3) + ordered_languages = project.languages.sort_by { |_, size| size }.reverse.first(3) + top_3 = ordered_languages.first(3).map {|l,s| l} label_issue(top_3) unless top_3.empty? end diff --git a/spec/workers/repo_checks_worker_spec.rb b/spec/workers/repo_checks_worker_spec.rb index 28075553..96536f44 100644 --- a/spec/workers/repo_checks_worker_spec.rb +++ b/spec/workers/repo_checks_worker_spec.rb @@ -72,7 +72,7 @@ describe "#detect_languages" do before do repo = OpenStruct.new(head: OpenStruct.new(target_id: 33)) - expected_languages = OpenStruct.new(languages: {"Ruby"=>176110, "HTML"=>664, "TeX"=>475, "Go"=>21}) + expected_languages = OpenStruct.new(languages: {"Go"=>21, "HTML"=>664, "Ruby"=>176110, "TeX"=>475, "XML" => 100}) allow(Rugged::Repository).to receive(:new).and_return(repo) allow(Linguist::Repository).to receive(:new).with(repo, 33).and_return(expected_languages) end