Skip to content

Commit

Permalink
Detect top 3 languages
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanxu committed Nov 17, 2023
1 parent 1f5ef17 commit 5eddedf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/workers/repo_checks_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/workers/repo_checks_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5eddedf

Please sign in to comment.