Skip to content

Commit

Permalink
fixup typo in group parsing setup task
Browse files Browse the repository at this point in the history
  • Loading branch information
estiens committed Nov 14, 2022
1 parent 033dd0b commit 750b2f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions config/puma.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if Rails.env.production?
workers Integer(ENV['WEB_CONCURRENCY'] || 3)
min_threads = Integer(ENV['MIN_THREADS'] || ENV['RAILS_MAX_THREADS'] || 8)
max_threads = Integer(ENV['RAILS_MAX_THREADS'] || 32)
min_threads = Integer(ENV['MIN_THREADS'] || ENV['RAILS_MAX_THREADS'] || 4)
max_threads = Integer(ENV['RAILS_MAX_THREADS'] || 8)

threads min_threads, max_threads
else
Expand Down
19 changes: 13 additions & 6 deletions lib/2022/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,29 @@ def self.setup_teams
end
end

def self.create_groups
%w[A B C D E F G H].each do |letter|
Group.find_or_create_by(letter: letter)
end
end

def self.parse_groups
create_groups unless Group.count == 8
group_json = File.read(Rails.root.join('lib/assets/wc2022/groups.json'))
JSON.parse(group_json)
end

def self.setup_groups
parse_groups.each do |g|
group = Group.find_or_create_by(letter: g.first[0])
group.teams = []
g.first[1].each do |name|
parse_groups.each do |data|
teams = data.first.last
group = Group.find_by(letter: data.first[0])
teams.each do |name|
team = Team.find_by(alternate_name: name) || Team.find_by(country: name)
raise "Could not find team for #{name}" unless team
next if group.teams.include? team

group.teams << team
team.update!(group: group)
end
group.save
end
end
end

0 comments on commit 750b2f9

Please sign in to comment.