Skip to content

Commit

Permalink
refactor(team.rb): Dividing large function
Browse files Browse the repository at this point in the history
Dividing randomize_all_by_parent method into
multiple sub methods

Change done by sjbarai
  • Loading branch information
darshil0193 committed Oct 28, 2017
1 parent 1d9a881 commit 01b3c75
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -520,3 +520,6 @@ DEPENDENCIES
uglifier
will_paginate
zip-zip

BUNDLED WITH
1.15.1
6 changes: 3 additions & 3 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ def self.randomize_all_by_parent(parent, team_type, min_team_size)
teams_num = teams.size
i = 0
teams_num.times do
team_users = TeamsUser.where(team_id: teams[i].id)
team_users.each do |team_user|
users.delete(User.find(team_user.user_id))
teams_users = TeamsUser.where(team_id: teams[i].id)
teams_users.each do |teams_user|
users.delete(User.find(teams_user.user_id))
end
if Team.size(teams.first.id) >= min_team_size
teams.delete(teams.first)
Expand Down

0 comments on commit 01b3c75

Please sign in to comment.