Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/matches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ def establish_match_entities(match)

return true if @radiant_team.nil?
if match.ended? && match.users_and_stats.present?
@radiant_team_avg = Team.rating_average @radiant_team
@dire_team_avg = Team.rating_average @dire_team
@radiant_team_avg = Team.rating_average @radiant_team, match
@dire_team_avg = Team.rating_average @dire_team, match
else
@radiant_team_avg = (@radiant_team.users.sum(:rating) / @radiant_team.users.count)
@dire_team_avg = (@dire_team.users.sum(:rating) / @dire_team.users.count)
Expand Down
4 changes: 2 additions & 2 deletions app/decorators/user_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def real_name
if object.real_name.nil?
markup = '(sin nombre real)'
elsif object.real_name.present? && object.real_middle_name && object.real_last_name
markup = object.real_name + ' ' + object.real_middle_name + ' ' + object.real_last_name
markup = object.real_name + ' ' + ' ' + object.real_last_name.first + '.'
elsif object.real_name.present? && object.real_last_name
markup = object.real_name + ' ' + object.real_last_name
markup = object.real_name + ' ' + object.real_last_name.first + '.'
end
h.content_tag(:i, markup.html_safe)
end
Expand Down
8 changes: 6 additions & 2 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ def team_rating_change(match, winner, radiant, dire)
end

# Calculates team average rating.
def rating_average(team)
sum = 0; team.users.each { |u| sum += u['rating'].to_i }
def rating_average(team, match)
if match.ended?
sum = 0; team.each { |u| sum += u['rating'].to_i }
else
sum = 0; team.users.each { |u| sum += u['rating'].to_i }
end
sum / 5
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/home/index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@
})
}
$('#user-table').DataTable({
"bAutoWidth": false,
"aoColumns" : [ { sWidth: "10%" }, { sWidth: "50%" }, { sWidth: "15%" }, { sWidth: "5%" }, { sWidth: "15%" }],
"bAutoWidth": false
"aoColumns" : [ { sWidth: "15%" }, { sWidth: "20%" }, { sWidth: "25%" }, { sWidth: "15%" }, { sWidth: "20%" }],
"bPaginate": false,
"showNEntries": false,
"bInfo":false,
Expand Down
2 changes: 1 addition & 1 deletion spec/models/match_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
fill_match_with_users(match, 10)

match.start
expect((Team.rating_average(match.teams.first)) - (Team.rating_average(match.teams.last)).abs).to be <= 6
expect((Team.rating_average(match.teams.first, match)) - (Team.rating_average(match.teams.last, match)).abs).to be <= 6
end

it 'should end a match and assign winner team correctly.' do
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
CodeClimate::TestReporter.start
require 'factory_girl'

Uncomment to exclude files for test coverage.
# Uncomment to exclude files for test coverage.
SimpleCov.start do
add_filter 'app/controllers/match_tokens_controller.rb'
add_filter 'app/controllers/match_tokens_controller.rb'
Expand Down
Loading