diff --git a/fetchers/base_rosters.rb b/fetchers/base_rosters.rb index fc14bd6..752a6bf 100644 --- a/fetchers/base_rosters.rb +++ b/fetchers/base_rosters.rb @@ -38,7 +38,11 @@ def fetch_rosters(ids) end def present_rosters(hash) - hash.flat_map do |_, players| + hash.flat_map do |team_id, players| + if players.is_a? String + puts "Malformed data for team #{team_id}, skipping it" + next + end players.flat_map do |player| { team_id: player['idteam'], @@ -48,6 +52,6 @@ def present_rosters(hash) end_date: player['dateRemoved'] } end - end + end.compact end end