Skip to content

Commit

Permalink
nil check for csv export (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArjunAranetaCodes authored Sep 13, 2024
1 parent 75c6af9 commit 0648dae
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,27 @@ def self.to_csv(competition)
# ENHANCEMENT: move to controller.
def self.compile_csv(competition, csv, project_columns)
competition.teams.published.preload(:current_project, :team_data_sets, :challenges, :assignments).each do |team|
csv << [
*team.current_project.attributes.values_at(*project_columns),
team.assignments.length,
team.team_data_sets.pluck(:url),
team.challenges.pluck(:name),
]
#csv << [
# *team.current_project.attributes.values_at(*project_columns),
# team.assignments.length,
# team.team_data_sets.pluck(:url),
# team.challenges.pluck(:name),
#]
if team.current_project
csv << [
*team.current_project.attributes.values_at(*project_columns),
team.assignments.length,
team.team_data_sets.pluck(:url),
team.challenges.pluck(:name),
]
else
# Handle the case where current_project is nil
csv << [nil] * project_columns.length + [
team.assignments.length,
team.team_data_sets.pluck(:url),
team.challenges.pluck(:name)
]
end
end
end

Expand Down

0 comments on commit 0648dae

Please sign in to comment.